Version 0 of A Little Access Log Viewer

Updated 2003-11-14 09:13:14

GPS: I was curious the other day about who might be visiting my website, so I enabled the access_log for the Roxen webserver used by my ISP, and magically it began to grow. It grew so much that it became unmanageable, so I came up with this in ~10 minutes. It makes reading a huge file much easier...

http://www.xmission.com/~georgeps/var/log_viewer.png

 #Copyright 2003 George Peter Staplin
 #You may use/copy/modify this under the same terms as Tcl.

 proc gradify.text w {
  set colorList [list black_red black_green white_blue]
  set end [lindex [split [$w index end] .] 0]
  set colorI 1
  for {set i 1} {$i < $end} {incr i} {
   $w tag add [lindex $colorList $colorI] $i.0 $i.end
   incr colorI
   if {$colorI > 2} {set colorI 0}
  }
  $w tag configure black_red -foreground black -background red
  $w tag configure black_green -foreground black -background green
  $w tag configure white_blue -foreground white -background blue 
 } 

 proc popup.selection.menu {w X Y} {
  set m .selpop
  destroy $m
  menu $m -tearoff 0
  $m add command -label Copy -command [list tk_textCopy $w]
  tk_popup $m $X $Y 
 }

 proc main {argc argv} {
  scrollbar .yview -command [list .t yview]
  text .t -yscrollcommand [list .yview set]
  bind .t <ButtonPress-3> [list popup.selection.menu .t %X %Y]
  grid .yview -sticky ns -row 0 -column 0
  grid .t -sticky news -row 0 -column 1
  grid rowconfigure . 0 -weight 100
  grid columnconfigure . 1 -weight 100
  .t insert end [read [set fd [open [lindex $argv 0] r]]];
  close $fd 
  gradify.text .t
 }
 main $::argc $::argv

Category Application