version 1.2, 2022/03/17 09:30:59 |
version 1.3, 2022/03/17 10:20:47 |
|
|
#include <syslog.h> |
#include <syslog.h> |
#include <time.h> |
#include <time.h> |
|
|
static int log_backgnd; |
static int log_background; |
static int log_verbose; |
static int log_verbose; |
const char *log_procname; |
const char *log_procname; |
|
|
Line 31 void log_info(const char *, ...) |
|
Line 31 void log_info(const char *, ...) |
|
void log_debug(const char *, ...) |
void log_debug(const char *, ...) |
__attribute__((__format__ (printf, 1, 2))); |
__attribute__((__format__ (printf, 1, 2))); |
|
|
|
|
void |
void |
log_init(int background, int facility) |
log_init(int background, int facility) |
{ |
{ |
Line 39 log_init(int background, int facility) |
|
Line 40 log_init(int background, int facility) |
|
if (__progname != NULL) |
if (__progname != NULL) |
log_procname = __progname; |
log_procname = __progname; |
|
|
log_backgnd = background; |
log_background = background; |
if (log_backgnd) |
if (log_background) |
openlog(log_procname, LOG_PID | LOG_NDELAY, facility); |
openlog(log_procname, LOG_PID | LOG_NDELAY, facility); |
|
|
tzset(); |
tzset(); |
Line 65 log_info(const char *info, ...) |
|
Line 66 log_info(const char *info, ...) |
|
|
|
va_start(ap, info); |
va_start(ap, info); |
|
|
if (log_backgnd) |
if (log_background) |
vsyslog(LOG_INFO, info, ap); |
vsyslog(LOG_INFO, info, ap); |
else { |
else { |
vfprintf(stderr, info, ap); |
vfprintf(stderr, info, ap); |
Line 83 log_debug(const char *info, ...) |
|
Line 84 log_debug(const char *info, ...) |
|
if (log_verbose) { |
if (log_verbose) { |
va_start(ap, info); |
va_start(ap, info); |
|
|
if (log_backgnd) |
if (log_background) |
vsyslog(LOG_INFO, info, ap); |
vsyslog(LOG_INFO, info, ap); |
else { |
else { |
vfprintf(stderr, info, ap); |
vfprintf(stderr, info, ap); |