It seems to me that a bug about logging still preserve
itself in the code since version 4.0.
logOff procedure closes logging file, logOn does not
re-open it. I'm not a TCL programmer, so probably
there is a better way to solve this than the one I'm
going to write; furthermore, I'm not sure the changes
I've done are unharmful.
This section should substitute the "# --- logging ---"
session on TSession.tcl, starting at about line 1017:
< begin of code >
# --- logging -----------------------------------------
------------
# fixes (?) (12/01/2002)
# Old system:
# CLogFID is opened file ID; it is assigned by
logfile, never cleared
# CLogFile is the name of current logfile
# CLogging is a flag, set if logging, unset otherwise
(see later)
#
# logfileExists{} returns 1 if a name has been
assigned to the log file,
# i.e. if CLogFile is not empty
# isLogging returns CLogging
# logfile{} if there is a current logfile (by
logfileExists), writes it
# to disk and then closes it; finally, assigns the new
logfile name
# to proper variable (CLogFile) and opens it
initializing CLogFID too.
# logOn sets CLogging
# logOff unsets CLogging and, if logfileExists,
flushes and closes it
# logToggle calls the proper logOn/Off procedure
according to CLogging
#
# external reference in writeMudText: if CLogging is
set, sends the string
# to CLogFID file too
#
# Potential (and not so) bug: after closing logfile by
logOff, if you reopen
# it by logOn, writeMudText will try to write lines to
a closed file (to
# prevent this, a call to logfile{} should precede any
call to logOn).
#
# Suggested solution:
# - simplest: let logOff re-open logfile (C&P from the
proper line in logfile{})
# - other: let logOn open logfile:
# -> logOn, logOff exit if called improperly (with
CLogging already 1 or 0)
# -> logOn opens logfile
# -> logfile closes and opens the file only if we are
already logging (i.e.
# if we only want to change logfile name)
# -> logOff always closes LogFile and clears its
CLogFID (to "")
#
body TSession::logfile {aFile} {
if {[isLogging]} {
flush $CLogFID
close $CLogFID
}
set CLogFile $aFile
if {[isLogging]} {
set CLogFID [open $CLogFile {WRONLY CREAT APPEND}]
}
}
body TSession::logfileExists {} {
if {[string compare "" $CLogFile]} {
return 1
} else {
return 0
}
}
body TSession::logOn {} {
if {[isLogging]} {
return
}
set CLogFID [open $CLogFile {WRONLY CREAT APPEND}]
set CLogging 1
}
body TSession::logOff {} {
if {![isLogging]} {
return
}
set CLogging 0
flush $CLogFID
close $CLogFID
set CLogFID ""
}
body TSession::logToggle {} {
set CLogging [expr !$CLogging]
if {[isLogging]} {
logOn
} else {
logOff
}
}
body TSession::isLogging {} {return $CLogging}
< end of code >
Logged In: YES
user_id=282934
See posting http://sourceforge.net/forum/forum.php?
thread_id=628464&forum_id=101619