Ignore:
Timestamp:
Oct 22, 2012, 7:51:31 PM (12 years ago)
Author:
mmc
Message:

Fixed the main program to catch kill signals and program termination
and flush the log buffer before exiting. Also saves "finished" as the
last message in the log.

Fixed the logger to see if the log directory is missing and warn about
it and turn off logging (rather than crapping out or trying to create
the log directory). The specific date for the log directory (e.g.,
/data/userlogs/2012-10-19) must be created by the middleware so that all
users can share it.

Added log messages for tooltips on the output quantities, and for almost
everything in the HeightmapViewer?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/logger.tcl

    r3186 r3187  
    9696        set dir [file join $env(RAPPTURE_LOG) $dir]
    9797        if {![file isdirectory $dir]} {
    98             file mkdir $dir
     98            puts stderr "WARNING: log directory \"$dir\" doesn't exist"
     99            return
    99100        }
    100101
     
    169170        proc ::Rappture::Logger::log {event args} { # do nothing }
    170171    }
     172
     173    # catch signals that kill the program and clean up logging
     174    package require Rappture
     175    Rappture::signal SIGHUP RapptureLogger ::Rappture::Logger::cleanup
     176    Rappture::signal SIGINT RapptureLogger ::Rappture::Logger::cleanup
     177    Rappture::signal SIGQUIT RapptureLogger ::Rappture::Logger::cleanup
     178    Rappture::signal SIGTERM RapptureLogger ::Rappture::Logger::cleanup
     179    Rappture::signal SIGKILL RapptureLogger ::Rappture::Logger::cleanup
    171180}
    172181
     
    182191    # do nothing by default until turned on by init
    183192}
     193
     194# ----------------------------------------------------------------------
     195# USAGE: cleanup
     196#
     197# Called when the program receives a signal that would normally kill
     198# the program.  Flushes the buffer and closes the log file cleanly
     199# before dying.
     200# ----------------------------------------------------------------------
     201proc Rappture::Logger::cleanup {} {
     202    variable enabled
     203    variable fid
     204
     205    if {$enabled && $fid ne ""} {
     206        log finished
     207        catch {flush $fid}
     208        catch {close $fid}
     209        set fid ""
     210        set enabled 0
     211    }
     212    after idle exit
     213}
Note: See TracChangeset for help on using the changeset viewer.