Log Messages
OOMMF defines a Tcl-based log class, Oc_Log, which is available
at the Tcl script level in all OOMMF applications. Messages are
specified using the syntax
Oc_Log Log message_content message_level
where message_content is an arbitrary string and
message_level is one of the predefined log levels: debug,
status, info, debug, warning, error, or
panic. Messages at level warning or higher are delivered by
default using the standard log handler, which is a pop-up window for
Tk-based applications or stderr for console applications.
Lower-level messages may be voluminous and are typically only useful for
debugging, so are not reported (i.e., swallowed) in OOMMF builds
configured for release. For development work, however, it can be useful
to record to a file all levels of log messages. This can be done
by including a code block similar to the following in the application
Tcl initialization code section, following the package require Oc
command:
Oc_FileLogger SetFile fubar.log
Oc_FileLogger StderrEcho 0
Oc_Log SetLogHandler [list Oc_FileLogger Log] panic
Oc_Log SetLogHandler [list Oc_FileLogger Log] error
Oc_Log SetLogHandler [list Oc_FileLogger Log] warning
Oc_Log SetLogHandler [list Oc_FileLogger Log] info
Oc_Log SetLogHandler [list Oc_FileLogger Log] status
Oc_Log SetLogHandler [list Oc_FileLogger Log] debug
Here fubar.log is an arbitrary name for the log file. Each run
will append to any preceding messages, so you may want to include a
start message such as
Oc_Log Log "*** Application fubar start ***" status
following the SetLogHandler commands to easily distinguish between
runs.
The Oc_FileLogger StderrEcho 0 command disables duplication of the
log messages to stderr. Replace 0 with 1 if you want log
messages written to both the log file and stderr.
Concerning stderr output on Windows, Tk enabled
OOMMF applications (e.g., mmLaunch and applications launched by
mmLaunch) are by default launched using WINDOWS subsystem
shell executables rather than ones built with the CONSOLE
subsystem. Writes to stdout and stderr from such applications
do not appear in the command prompt console window. To change this,
launch the application directly using the console variant of the shell
executable, e.g.,
> oommf mmlaunch +command
app/omfsh/windows-x86_64/omfsh.exe app/mmlaunch/mmlaunch.tcl &
> dir /w app\omfsh\windows-x86_64
Directory of oommf\app\omfsh\windows-x86_64
[.] [..] appindex.tcl filtersh.exe omfsh.exe omfsh.obj
> app\omfsh\windows-x86_64\filtersh app\mmlaunch\mmlaunch.tcl
In this example the OOMMF application mmlaunch uses the
omfsh (WINDOWS subsystem) shell by default, so we replace this
with filtersh. The corresponding command to run mmDisp would
be
> app\mmdisp\windows-x86_64\condispsh app\mmdisp\scripts\mmdisp.tcl
where condispsh stands in for mmdispsh.
OOMMF Documentation Team
September 27, 2024