MLIB
Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1#pragma once
11#if __has_include("defs.h")
12#include "defs.h"
13#endif
14
15#include <winsock2.h>
16
17// facility codes 0 to 24 are defined in syslog.h
18#define LOG_USER (1 << 3)
19
28#define LOG_EMERG 0
29#define LOG_ALERT 1
30#define LOG_CRIT 2
31#define LOG_ERR 3
32#define LOG_WARNING 4
33#define LOG_NOTICE 5
34#define LOG_INFO 6
35#define LOG_DEBUG 7
37
45#define LOG_PRIMASK 0x7
46#define LOG_FACMASK 0x03f8
47#define LOG_MASK(pri) (1 << (pri))
48#define LOG_UPTO(pri) ((1 << ((pri) + 1)) - 1)
50#define LOG_MAKEPRI(fac, pri) ((fac) | (pri))
52
60/*
61 * LOG_ODELAY no longer does anything.
62 * LOG_NDELAY is the inverse of what it used to be.
63 */
64#define LOG_PID 0x01 /* log the pid with each message */
65#define LOG_CONS 0x02 /* log on the console if errors in sending */
66#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
67#define LOG_NDELAY 0x08 /* don't delay open */
68#define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */
69#define LOG_PERROR 0x20 /* log to stderr as well */
70
71// mlib stuff
72#define LOGOPT_PID 0x01
73#define LOGOPT_OUTDEBUG 0x02
74
75#define LOGOPT_NOUDP 0x40
76#define LOGOPT_FILE 0x80
78
79#define LOG_PORT 514 /* port number for logger (same as SYSLOG service) */
80
81#ifdef __cplusplus
82extern "C"
83{
84#endif
85
87 void closelog (void);
88
90 void openlog (const char* ident, int option, int facility);
91
93 int setlogmask (int mask);
94
96 int setlogopt (int opt);
97
99 void syslog (int facility_priority, const char* fmt, ...);
100
102 bool syslog_debug (const char* fmt, ...);
103
105 extern int log_defaultopt;
106
108 extern char log_servhostname[_MAX_PATH];
109
111 extern char log_fname[_MAX_PATH];
112
113#ifdef __cplusplus
114}
115#endif
void closelog(void)
Close connection to logger.
Definition log.cpp:234
void openlog(const char *ident, int option, int facility)
Open connection to logger.
Definition log.cpp:157
int setlogmask(int mask)
Set the log mask level.
Definition log.cpp:401
void syslog(int facility_priority, const char *fmt,...)
Generate a log message using FMT string and option arguments.
Definition log.cpp:279
int setlogopt(int opt)
Set option flags.
Definition log.cpp:427
char log_fname[_MAX_PATH]
Log filename if LOGOPT_FILE flag is set.
Definition log.cpp:44
int log_defaultopt
Default log options - combination of LOGOPT_... flags.
Definition log.cpp:41
bool syslog_debug(const char *fmt,...)
Generate a log message at debug level using FMT string and option arguments.
Definition log.cpp:318
char log_servhostname[_MAX_PATH]
Destination host for UDP datagrams. Default is "localhost".
Definition log.cpp:43