The personal logger API library module has the file name logger.c. This module provides a single user message logging service. The module global variable p_islog is the log switch. All logging function 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:
You can compile this module and place the object code into a library and link the library into your program. You can also just include this module into your make routine. No other modules are required in order to use the personal logger.
This module requires the header file logger.h which is automatically included from the header file enhlib.h which is automatically included from header file stdhead.h.
Prototype : int log_start(char *fname) Parameters : Name : fname Description: drive/path/file name Returns : TRUE if successful, FALSE otherwise
This function starts the logger sending all log data to the drive/path/file name. The log fname may be NULL or empty if the logger interface has already been successfully initialized during the current application run. When this function is called with a NULL or empty fname, logging will re-start with the previously registered log file name.
Prototype : void logger(char *fmt,...) Parameters : Name : fmt Description: printf style format string
This printf style function will send a string to the log file. The function log_start must have already been called. Message is logged by calling the function log_file.
Prototype : void log_file(char *fmt,...) Parameters : Name : fmt Description: printf style format string
This printf style function will output the message to the log file. The function log_start must have already been called.
Prototype : void log_file_date(char *fmt,...) Parameters : Name : fmt Description: printf style format string
This printf style function will output the message to the log file with a date/time prefix. The function log_start must have already been called.
Prototype : void log_file_date_nf(char *mes) Parameters : Name : mes Description: message text
This function operates just like log_file_date except that a variable number of arguments is not used.
Prototype : void log_disp(char *fmt,...) Parameters : Name : fmt Description: printf style format string
This printf style function will output the message to the screen. The function log_start must have already been called.
Prototype : int is_log_active(void) Returns : TRUE if logger is active, FALSE otherwise
This function will return the value of the logger flag p_islog.
Prototype : void log_end(void)
This function will end the logger by turning off the p_islog switch.
Prototype : int log_file_name(char *lfname) Parameters : Name : lfname Description: returned drive/path/file name Returns : TRUE if successful, FALSE otherwise
This function will return the current log file name in use. The logger interface must have already been previously initialized at least once by calling the function log_start.
Prototype : void log_console(int flag) Parameters : Name : flag Description: zero or one
This function will turn console/screen output of all log data on or off by modifying the p_console_output module global variable.
Prototype : int log_get_console(void) Returns : current value of p_console_output
This function will return the current value of the console/screen output flag p_console_output.
Prototype : int sys_log(char *fmt,...) Parameters : Name : fmt Description: printf style format string
This printf style function is provided as a stub only for the DOS platform since there is no system logger for DOS.