MWLOG

Section: MidWay Programmer's Manual (3)
Updated: DATE
Index Return to Main Contents
 

NAME

mwlog mwloglevel, mwlogprefix - MidWay logging facility  

SYNOPSIS

#include <MidWay.h>

void mwlog(int level, char * fmt, ...);

void mwloglevel(int level);
void mwlogprefix(char * fileprefix);
void mwlogprefix(char * progname, chat * fileprefix, int level);  

DESCRIPTION

These calls constitute the logging facility in MidWay. This facility are used in MidWay code and is provided here to give programmers a unified program log. There are nothing that prevent a programmer to use stdout and stderr, but be aware that if level is set to MWLOG_DEBUG or above, logging is performed to stderr as well as the log file. After the level argument to mwlog() it behaves just like printf(3) with one exception, an newline is automatically added. As syslog each entry made by mwlog() in the logfile is prefixed by a time stamp, the calling pid, and loglevel.
To set what level of log messages to ignore and what to write to log file we set level with mwlogprefix(). All logging above this loglevel is ignored.
The default log fileprefix is ./userlog.YYYYMMDD The date suffix is alway added to the logfile and the filename is automatically switched after midnight.

Note that progname is limited to 8 chars. If NULL, mwlog() will not insert blanks in the logentries.


The level parameter is similar to that of syslog(3) that it indicate severity of the entry..

MWLOG_DEBUG4
Reserved for differentiate logging done in MidWay code on DEBUG3
MWLOG_DEBUG3
A rather extreme level of debugging, and will produce a vast number of logging from MidWay code. Normally only used for developing and debugging MidWay code.
MWLOG_DEBUG2
Reserved for programmers to give excessive logging without being out drowned by logging from MidWay code.
MWLOG_DEBUG1
Some debugging from MidWay code, more meant to be helpful for programmers to see when execution swaps between their own code and MidWays.
MWLOG_DEBUG
Reserved for programmers to have a debugging facility without any from MidWay code.
MWLOG_INFO
The default log level, which is meant to give enough to be able to go back and see when servers started and stopped, when services were provided, and unprovided, when network connections where established and disconnected.
MWLOG_ALERT
Warning messages that indicate that some action are needed in order to prevent loss of service.
MWLOG_WARNING
Warning messages that will indicate conditions that will not cause loss of service, but threatens.
MWLOG_ERROR
Out right errors.

MWLOG_FATAL
Critical errors that will cause an abort/shutdown.

 

WARNINGS

mwlog() do not close the logfile between to writes, thus all processes using this logfile have it open for writing. Attempting to remove the logfile by rm will only unlink it, but not remove the inode. (Common problem). Check it with lsof or fuser before removing.

 

EXAMPLES

 

BUGS

Even if mwlog() flushes the log on every write, there are no file locking, and corruption of the logfile may occur.
If you use a relative or absolute path in mwloprefix(), and we fail to open the file, we silently drop all logging.  

SEE ALSO

MidWay(7)

 

STANDARDS

These calls are somewhat inspired by syslog and the logging facility in CA/Unicenter AgentWorks.


 

Index

NAME
SYNOPSIS
DESCRIPTION
WARNINGS
EXAMPLES
BUGS
SEE ALSO
STANDARDS

This document was created by man2html, using the manual pages.
Time: 11:18:50 GMT, October 24, 2000