this code ...
...is a proof of concept of a highlighter algorithm for a logdisplayer that - if proofed useful - will be rewritten in javascript/html
from:
to
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