MLIB
Loading...
Searching...
No Matches
log.h File Reference

syslog related functions. More...

#include <winsock2.h>

Go to the source code of this file.

Macros

#define LOG_USER   (1 << 3)
 facility for random user-level messages
 
#define LOG_PORT   514 /* port number for logger (same as SYSLOG service) */
 
Priorities

priorities/facilities are encoded into a single 32-bit quantity, where the bottom 3 bits are the priority (0-7) and the top 28 bits are the facility (0-big number).

This is the mapping of priority codes.

#define LOG_EMERG   0
 system is unusable
 
#define LOG_ALERT   1
 action must be taken immediately
 
#define LOG_CRIT   2
 critical conditions
 
#define LOG_ERR   3
 error conditions
 
#define LOG_WARNING   4
 warning conditions
 
#define LOG_NOTICE   5
 normal but significant condition
 
#define LOG_INFO   6
 informational
 
#define LOG_DEBUG   7
 debug-level messages
 
Masks and Operations

The following definitions can be used for operations on priorities and facilities.

See syslog() and setlogmask() for examples.

#define LOG_PRIMASK   0x7
 mask to extract priority part
 
#define LOG_FACMASK   0x03f8
 mask to extract facility part
 
#define LOG_MASK(pri)
 mask for one priority
 
#define LOG_UPTO(pri)
 
#define LOG_MAKEPRI(fac, pri)
 Used for arguments to syslog.
 
Flags for openlog

The following flags can be specified in the opt argument of openlog():

BSD stuff

#define LOG_PID   0x01 /* log the pid with each message */
 log the process id with each message
 
#define LOG_CONS   0x02 /* log on the console if errors in sending */
 log the process id with each message
 
#define LOG_ODELAY   0x04 /* delay open until first syslog() (default) */
 log the process id with each message
 
#define LOG_NDELAY   0x08 /* don't delay open */
 log the process id with each message
 
#define LOG_NOWAIT   0x10 /* don't wait for console forks: DEPRECATED */
 log the process id with each message
 
#define LOG_PERROR   0x20 /* log to stderr as well */
 log the process id with each message
 
#define LOGOPT_PID   0x01
 log the process id with each message
 
#define LOGOPT_OUTDEBUG   0x02
 log to Windows debug port (OutputDebugString)
 
#define LOGOPT_NOUDP   0x40
 do not send UDP data
 
#define LOGOPT_FILE   0x80
 log to disk file
 

Functions

void closelog (void)
 Close connection to logger.
 
void openlog (const char *ident, int option, int facility)
 Open connection to logger.
 
int setlogmask (int mask)
 Set the log mask level.
 
int setlogopt (int opt)
 Set option flags.
 
void syslog (int facility_priority, const char *fmt,...)
 Generate a log message using FMT string and option arguments.
 
bool syslog_debug (const char *fmt,...)
 Generate a log message at debug level using FMT string and option arguments.
 

Variables

int log_defaultopt
 Default log options - combination of LOGOPT_... flags.
 
char log_servhostname [_MAX_PATH]
 Destination host for UDP datagrams. Default is "localhost".
 
char log_fname [_MAX_PATH]
 Log filename if LOGOPT_FILE flag is set.
 

Detailed Description

syslog related functions.

(c) Mircea Neacsu 2008

The header file is a shameless copy of the original BSD syslog.h file, however implementations are new.

Macro Definition Documentation

◆ LOG_MAKEPRI

#define LOG_MAKEPRI ( fac,
pri )
Value:
((fac) | (pri))

Used for arguments to syslog.

◆ LOG_MASK

#define LOG_MASK ( pri)
Value:
(1 << (pri))

mask for one priority

◆ LOG_UPTO

#define LOG_UPTO ( pri)
Value:
((1 << ((pri) + 1)) - 1)

all priorities through pri