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

Lazy Evaluation(there be dragons and basement cats)

Lazy Evaluation and "undefined" I am on the road to being a haskell programmer, and it still is a long way to go. Yesterday I had some nice guys from #haskell explain to me lazy evaluation. Take a look at this code: Prelude> let x = undefined in "hello world" "hello world" Prelude> Because of Haskells lazyness, x will not be evaluated because it is not used, hence undefined will not be evaluated and no exception will occur. The evaluation of "undefined" will result in a runtime exception: Prelude> undefined *** Exception: Prelude.undefined Prelude> Strictness Strictness means that the result of a function is undefined, if one of the arguments, the function is applied to, is undefined. Classical programming languages are strict. The following example in Java will demonstrate this. When the programm is run, it will throw a RuntimeException, although the variable "evilX" is never actually used, strictness requires that all argu

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

Erlang mock - erlymock

NOTE THIS POST IS OUTDATED! The project has evolved and can be found here: ErlyMock Some features Easy to use Design based on easymock Works together with otp: can be used even if the clut is called from another process, by invoking mock:verify_after_last_call(Mock,optional: timeout) custom return functions predefined return functions for returning values, receiving message, throwing exceptions, etc.. erlymock automatically purges all modules that were mocked, after verify() Custom argument matchers: %% Orderchecking types: in_order, out_of_order, stub; %% Answering: {return, ...}|{error, ...}|{throw, ...}|{exit, ...}|{rec_msg, Pid}|{function, Fun(Args) -> RetVal} expect(Mock, Type, Module, Function, Arguments, Answer = {AT, _}) when AT==return;AT==error;AT==throw;AT==exit;AT==rec_msg;AT==function -> call(Mock, {expect, Type, Module, Function, length(Arguments), {Arguments, Answer}}). %% this version of expect is suited for useing custom argument matchers expect(Mock, Type,