Skip to main content

logs display, little experiment

this code ...


module LogDiffMarker where

type ReferenceWords = [String]
type Lines = [Line]
type Line = String

mark_diffrent_words :: (ReferenceWords, Lines) -> Line -> (ReferenceWords, Lines)
mark_diffrent_words (ref,i) line = (next_ref, i ++ [unwords line_with_em])
where (line_with_em, next_ref) = mark_diffrences (words line) ref ([],[])
mark_diffrences l1 [] (line_acc, ref_acc) = (line_acc ++ ["<b>"] ++ l1 ++ ["</b>"], ref_acc ++ l1)
mark_diffrences [] r (line_acc, ref_acc) = (line_acc, ref_acc)
mark_diffrences (h1:t1) (h2:t2) (line_acc, ref_acc)
| h1 == h2 = mark_diffrences t1 t2 (line_acc ++ [h1] ,ref_acc ++ [h2])
| otherwise = mark_diffrences t1 t2 (line_acc ++ ["<b>" ++ h1 ++ "</b>"],ref_acc ++ [h1])

mark_diffrent_lines :: Lines -> Lines
mark_diffrent_lines = (["<pre>"]++) . (++["</pre>"]) . snd . (foldl mark_diffrent_words ([], []))

main = interact (unlines . mark_diffrent_lines . lines)


...is a proof of concept of a highlighter algorithm for a logdisplayer that - if proofed useful - will be rewritten in javascript/html

from:

May 10 05:52:19 ubuntu syslogd 1.5.0#1ubuntu1: restart.
May 10 06:22:02 ubuntu -- MARK --
May 10 06:42:02 ubuntu -- MARK --
May 10 06:51:49 ubuntu kernel: [ 2145.672201] nautilus[6101]: segfault at e1000020 eip b773f2d6 esp bfe4d9d0 error 5
May 10 06:51:51 ubuntu kernel: [ 2147.588620] gdm[5658]: segfault at 10c03f90 eip b7801635 esp bf8100e0 error 4
May 10 06:51:53 ubuntu kernel: [ 2149.171081] ip6_tables: (C) 2000-2006 Netfilter Core Team
May 10 06:51:54 ubuntu exiting on signal 15
May 12 19:07:04 ubuntu syslogd 1.5.0#1ubuntu1: restart.
May 12 19:07:04 ubuntu kernel: Inspecting /boot/System.map-2.6.24-16-generic
May 12 19:07:04 ubuntu kernel: Loaded 27704 symbols from /boot/System.map-2.6.24-16-generic.
May 12 19:07:04 ubuntu kernel: Symbols match kernel version 2.6.24.
May 12 19:07:05 ubuntu kernel: Loaded 32155 symbols from 83 modules.
May 12 19:07:05 ubuntu kernel: [ 0.000000] Linux version 2.6.24-16-generic (buildd@palmer) (gcc version 4.2.3 (Ubuntu 4.2.3
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-provided physical RAM map:
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-e820: 0000000000000000 - 000000000009f800 (usable)
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-e820: 000000000009f800 - 00000000000a0000 (reserved)
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-e820: 0000000000100000 - 000000007fff0000 (usable)
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-e820: 000000007fff0000 - 000000007fff3000 (ACPI NVS)
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-e820: 000000007fff3000 - 0000000080000000 (ACPI data)
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-e820: 00000000d0000000 - 00000000e0000000 (reserved)
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-e820: 00000000fec00000 - 0000000100000000 (reserved)
May 12 19:07:05 ubuntu kernel: [ 0.000000] 1151MB HIGHMEM available.
May 12 19:07:05 ubuntu kernel: [ 0.000000] 896MB LOWMEM available.
May 12 19:07:05 ubuntu kernel: [ 0.000000] found SMP MP-table at 000f52c0
May 12 19:07:05 ubuntu kernel: [ 0.000000] Zone PFN ranges:
May 12 19:07:05 ubuntu kernel: [ 0.000000] DMA 0 -> 4096
May 12 19:07:05 ubuntu kernel: [ 0.000000] Normal 4096 -> 229376
May 12 19:07:05 ubuntu kernel: [ 0.000000] HighMem 229376 -> 524272
May 12 19:07:05 ubuntu kernel: [ 0.000000] Movable zone start PFN for each node
May 12 19:07:05 ubuntu kernel: [ 0.000000] early_node_map[1] active PFN ranges
May 12 19:07:05 ubuntu kernel: [ 0.000000] 0: 0 -> 524272
May 12 19:07:05 ubuntu kernel: [ 0.000000] DMI 2.3 present.
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: RSDP signature @ 0xC00F6C50 checksum 0
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: RSDP 000F6C50, 0014 (r0 Nvidia)
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: RSDT 7FFF3000, 0030 (r1 Nvidia AWRDACPI 42302E31 AWRD 1010101)
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: FACP 7FFF3040, 0074 (r1 Nvidia AWRDACPI 42302E31 AWRD 1010101)
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: DSDT 7FFF30C0, 4BF2 (r1 NVIDIA AWRDACPI 1000 MSFT 100000C)
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: FACS 7FFF0000, 0040
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: MCFG 7FFF7D40, 003C (r1 Nvidia AWRDACPI 42302E31 AWRD 1010101)
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: APIC 7FFF7CC0, 007C (r1 Nvidia AWRDACPI 42302E31 AWRD 1010101)
May 12 19:07:05 ubuntu kernel: [ 0.000000] Nvidia board detected. Ignoring ACPI timer override.
May 12 19:07:05 ubuntu kernel: [ 0.000000] If you got timer trouble try acpi_use_timer_override
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: PM-Timer IO Port: 0x1008


to


May 10 05:52:19 ubuntu syslogd 1.5.0#1ubuntu1: restart.
May 10 06:22:02 ubuntu -- MARK --
May 10 06:42:02 ubuntu -- MARK --
May 10 06:51:49 ubuntu kernel: [ 2145.672201] nautilus[6101]: segfault at e1000020 eip b773f2d6 esp bfe4d9d0 error 5
May 10 06:51:51 ubuntu kernel: [ 2147.588620] gdm[5658]: segfault at 10c03f90 eip b7801635 esp bf8100e0 error 4
May 10 06:51:53 ubuntu kernel: [ 2149.171081] ip6_tables: (C) 2000-2006 Netfilter Core Team
May 10 06:51:54 ubuntu exiting on signal 15
May 12 19:07:04 ubuntu syslogd 1.5.0#1ubuntu1: restart.
May 12 19:07:04 ubuntu kernel: Inspecting /boot/System.map-2.6.24-16-generic
May 12 19:07:04 ubuntu kernel: Loaded 27704 symbols from /boot/System.map-2.6.24-16-generic.
May 12 19:07:04 ubuntu kernel: Symbols match kernel version 2.6.24.
May 12 19:07:05 ubuntu kernel: Loaded 32155 symbols from 83 modules.
May 12 19:07:05 ubuntu kernel: [ 0.000000] Linux version 2.6.24-16-generic (buildd@palmer) (gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)) #1 SMP Thu Apr 10 13:23:42 UTC 2008 (Ubuntu 2.6.24-16.30-generic)
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-provided physical RAM map:
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-e820: 0000000000000000 - 000000000009f800 (usable)
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-e820: 000000000009f800 - 00000000000a0000 (reserved)
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-e820: 0000000000100000 - 000000007fff0000 (usable)
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-e820: 000000007fff0000 - 000000007fff3000 (ACPI NVS)
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-e820: 000000007fff3000 - 0000000080000000 (ACPI data)
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-e820: 00000000d0000000 - 00000000e0000000 (reserved)
May 12 19:07:05 ubuntu kernel: [ 0.000000] BIOS-e820: 00000000fec00000 - 0000000100000000 (reserved)
May 12 19:07:05 ubuntu kernel: [ 0.000000] 1151MB HIGHMEM available.
May 12 19:07:05 ubuntu kernel: [ 0.000000] 896MB LOWMEM available.
May 12 19:07:05 ubuntu kernel: [ 0.000000] found SMP MP-table at 000f52c0
May 12 19:07:05 ubuntu kernel: [ 0.000000] Zone PFN ranges:
May 12 19:07:05 ubuntu kernel: [ 0.000000] DMA 0 -> 4096
May 12 19:07:05 ubuntu kernel: [ 0.000000] Normal 4096 -> 229376
May 12 19:07:05 ubuntu kernel: [ 0.000000] HighMem 229376 -> 524272
May 12 19:07:05 ubuntu kernel: [ 0.000000] Movable zone start PFN for each node
May 12 19:07:05 ubuntu kernel: [ 0.000000] early_node_map[1] active PFN ranges
May 12 19:07:05 ubuntu kernel: [ 0.000000] 0: 0 -> 524272
May 12 19:07:05 ubuntu kernel: [ 0.000000] DMI 2.3 present.
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: RSDP signature @ 0xC00F6C50 checksum 0
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: RSDP 000F6C50, 0014 (r0 Nvidia)
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: RSDT 7FFF3000, 0030 (r1 Nvidia AWRDACPI 42302E31 AWRD 1010101)
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: FACP 7FFF3040, 0074 (r1 Nvidia AWRDACPI 42302E31 AWRD 1010101)
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: DSDT 7FFF30C0, 4BF2 (r1 NVIDIA AWRDACPI 1000 MSFT 100000C)
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: FACS 7FFF0000, 0040
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: MCFG 7FFF7D40, 003C (r1 Nvidia AWRDACPI 42302E31 AWRD 1010101)
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: APIC 7FFF7CC0, 007C (r1 Nvidia AWRDACPI 42302E31 AWRD 1010101)
May 12 19:07:05 ubuntu kernel: [ 0.000000] Nvidia board detected. Ignoring ACPI timer override.
May 12 19:07:05 ubuntu kernel: [ 0.000000] If you got timer trouble try acpi_use_timer_override
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: PM-Timer IO Port: 0x1008
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled)
May 12 19:07:05 ubuntu kernel: [ 0.000000] Processor #0 15:3 APIC version 16
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: LAPIC (acpi_id[0x01] lapic_id[0x01] enabled)
May 12 19:07:05 ubuntu kernel: [ 0.000000] Processor #1 15:3 APIC version 16
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: LAPIC_NMI (acpi_id[0x00] dfl dfl lint[0x1])
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: LAPIC_NMI (acpi_id[0x01] dfl dfl lint[0x1])
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: IOAPIC (id[0x02] address[0xfec00000] gsi_base[0])
May 12 19:07:05 ubuntu kernel: [ 0.000000] IOAPIC[0]: apic_id 2, version 17, address 0xfec00000, GSI 0-23
May 12 19:07:05 ubuntu kernel: [ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)

Comments

Popular posts from this blog

Learning Haskell, functional music

As you might have realized, I started to learn Haskell. One of the most fun things to do in any programming language is creating some kind of audible side effects with a program. Already back in the days when I started programming, I always played around with audio when toying around with a new language. I have found a wonderful set of lecture slides about haskell and multimedia programming, called school of expression. Inspired by the slides about functional music I implemented a little song. Ahh ... and yes it is intended to sound slightly strange . I used the synthesis toolkit to transform the music to real noise, simply by piping skini message to std-out. I used this command line to achieve the results audible in the table: sven@hhi1214a:~/Mukke$ ghc -o test1 test1.hs && ./test1 | stk-demo Plucked -n 16 -or -ip Sound samples: Plucked play Clarinet play Whistle(attention very crazy!) play As always the source... stueck = anfang :+: mitte :+: ende anfang = groovy :+: (Trans

The purpose of the MOCK

In response to a much nicer blog entry, that can be found here . There are actually several distinct "tests" that make up usual unit tests, among them two that really do stand out: one kind of testing to test method flows, one to test some sort of computation. Mock objects are for the purpose of testing method flows. A method flow is a series of message transmissions to dependent objects. The control flow logic inside the method(the ifs and whiles) will alter the flow in repsonse to the parameters of the method call parameters passed by calling the method under test, depending on the state of the object that contains the method under test and the return values of the external method calls(aka responses to the messages sent). There should be one test method for every branch of an if statement, and usuale some sort of mock control objects in the mock framework will handle loop checking. BTW: I partly use message transmission instead of method invocation to include other kind

Keys, Values and Rules: Three Important Shake Concepts

The title was a click-bait! This article will actually try to explain five instead of three important notions in Shake. These are: Rules Keys Values The Build Database Actions This short blog post was inspired by the hurdles with my Shake based build, after the new Shake version was released, which had breaking API changes. Jump to the next section if you are not interested in the why and how of this blog post. Shake is rule based build system much like GNU make. Like make it is robust, unlike make, it is pretty fast and supports dynamic build dependencies. But you knew all that already, if you are the target audience of this post, since this post is about me explaining to myself by explaining to you, how that build tool, I used for years, actually works. Although I used it for years, I never read the paper or wrapped my head around it more than absolutely necessary to get the job done. When Shake was updated to version 0.16.x, the internal API for custom rules w