Tcl Personal Logger API Library Module

The Tcl personal logger API library module has the file name logger.tcl. This module provides a single user message logging service. The module global variable p_islog is the log switch. All logging procedure calls will immediately return if the log switch is off. The global variable p_has_init is used to indicate whether the logger interface has been successfully initialized and the global variable p_console_output is used to allow/disallow console/screen output.

The log file is kept closed except when writing a message to the log file. This method is slower than keeping the log file open but is almost crash proof. If the application using the personal logger crashes, the log file will be closed. All data written to the log file is in append mode.

Here is a list of functions in the personal logger API library module:

Module Dependencies

The following modules are required along with this module:

Module Definition Files

This module requires the definition file:

Module Procedures

log_start

Declaration  : proc log_start {fname}
Parameters   :
      Name   : fname
      Type   : path string
Description  : drive/path/file name

Returns      : 1 if successful, 0 otherwise

This procedure starts the logger sending all log data to the drive/path/file name. The log drive/path/file name may be empty if the logger interface has already been successfully initialized during the current application run. When this procedure is called with an empty drive/path/file name, logging will re-start with the previously registered log file name.

logger

Declaration  : proc logger {mes}
Parameters   :
      Name   : mes
      Type   : string
Description  : message string

This procedure will send the message string to the log file. The procedure log_start must have already been called. Message is logged by calling the procedure log_file.

log_file

Declaration  : proc log_file {mes}
Parameters   :
      Name   : mes
      Type   : string
Description  : message string

This procedure will output the message string to the log file. The procedure log_start must have already been called.

log_file_date

Declaration  : proc log_file_date {mes}
Parameters   :
      Name   : mes
      Type   : string
Description  : message string

This procedure will output the message string to the log file with a date/time prefix. The procedure log_start must have already been called.

log_disp

Declaration  : proc log_disp {mes}
Parameters   :
      Name   : mes
      Type   : string
Description  : message string

This procedure will output the message string to the screen. The procedure log_start must have already been called.

is_log_active

Declaration  : proc is_log_active {}
Returns      : 1 if logger is active, 0 otherwise

This procedure will return the value of the logger flag p_islog.

log_end

Declaration  : proc log_end {}

This procedure will end the logger by turning off the p_islog switch.

log_file_name

Declaration  : proc log_file_name {lfname}
Parameters   :
      Name   : lfname
      Type   : string
Description  : returned drive/path/file name

Returns      : 1 if successful, 0 otherwise

This procedure will return the current log file name in use. The logger interface must have already been previously initialized at least once by calling the procedure log_start.

log_console

Declaration  : proc log_console {flag}
Parameters   :
      Name   : flag
      Type   : boolean number
Description  : zero or one

This procedure will turn console/screen output of all log data on or off by modifying the p_console_output module global variable.

log_get_console

Declaration  : proc log_get_console {}
Returns      : current value of the p_console_output flag

This procedure will return the current value of the console/screen output flag p_console_output.

Goto Top | Tcl Applications | Tcl Software Overview | Tcl Library Overview
| Future Lab Home | Contact Webmaster | Feedback

Copyright © 2005-2006 Future Lab, Last Updated Jul 01, 2006