Version 2 of A Little Access Log Viewer

Updated 2003-11-14 09:34:00

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 black_cyan black_orange]
  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 > 3} {set colorI 0}
  }
  $w tag configure black_red -background black -foreground red
  $w tag configure black_green -background black -foreground green
  $w tag configure black_cyan -background black -foreground cyan
  $w tag configure black_orange -background black -foreground orange 
 }

 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

You might also have a look at WeSeLo, which breaks things down so that you can easily see multiple visits attached to the host they are coming from, replay old logs, and so on...


Category Application