Changeset 3187 for trunk/gui/scripts/logger.tcl
- Timestamp:
- Oct 22, 2012, 7:51:31 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/logger.tcl
r3186 r3187 96 96 set dir [file join $env(RAPPTURE_LOG) $dir] 97 97 if {![file isdirectory $dir]} { 98 file mkdir $dir 98 puts stderr "WARNING: log directory \"$dir\" doesn't exist" 99 return 99 100 } 100 101 … … 169 170 proc ::Rappture::Logger::log {event args} { # do nothing } 170 171 } 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 171 180 } 172 181 … … 182 191 # do nothing by default until turned on by init 183 192 } 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 # ---------------------------------------------------------------------- 201 proc 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.