CLOG(3)

NAME
clog - Copious Logger

SYNOPSIS
#include <clog.h>
void
clog_init(int no_syslog);
int
clog_set_flags(u_int32_t flags);
int
clog_set_logfile(const char *logfile);
void
clog_set_mask(u_int64_t mask);
void
clog_version(int *major, int *minor, int *patch);
void
CNINFO(u_int64_t mask, const char *format, ...);
void
CINFO(const char *format, ...);
void
CNDBG(u_int64_t mask, const char *format, ...);
void
CDBG(const char *format, ...);
void
CNWARNX(u_int64_t mask, const char *format, ...);
void
CWARNX(const char *format, ...);
void
CNWARN(u_int64_t mask, const char *format, ...);
void
CWARN(const char *format, ...);
void
CNFATALX(u_int64_t mask, const char *format, ...);
void
CFATALX(const char *format, ...);
void
CNFATAL(u_int64_t mask, const char *format, ...);
void
CFATAL(const char *format, ...);
void
CNABORTX(u_int64_t mask, const char *format, ...);
void
CABORTX(const char *format, ...);
void
CNABORT(u_int64_t mask, const char *format, ...);
void
CABORT(const char *format, ...);

DESCRIPTION
clog_init() prepares the library for first use. This function should be called before any other function is called.

clog_set_flags() sets the operational flags for clog. Possible values are:
CLOG_F_FILE
    Log source file name.
CLOG_F_FUNC
    Log source function name.
CLOG_F_LINE
    Log source file line number.
CLOG_F_PID
    Log program name and PID.
CLOG_F_DATE
    Log date in ctime(3) format.
CLOG_F_DTIME
    Log delta time from previous log function invocation. This time delta has micro second resolution.
CLOG_F_FILOG
    Log to logfile which is given as an argument to clog_set_logfile(). The clog_set_logfile() function must be called before setting this flag.
CLOG_F_STDERR
    Log to stderr.
CLOG_F_SYSLOG
    Log to syslog(3). Note that syslog(3) always prepends the ctime(3) date. Currently all clog output goes to LOG_DAEMON.
CLOG_F_ENABLED
    Enable logging.
CLOG_F_DBGENABLE
    Enable debug logging.

Only supported flags can be set and this function will return 0 on success and 1 on failure.

clog_set_logfile() sets the log file to log to when CLOG_F_FILOG is set. This function must be called before setting CLOG_F_FILOG. The returned value is 0 on success and 1 on failure.

clog_set_mask() sets external debug mask. The debug mask must be a bitfield and must be defined by the caller. It is used to control what to log and what to skip.

clog_version() gets the current version of the library at run time.

All logging functions use the format as defined by printf(3). The N in the name of the logging functions designates the use of a mask.

CNINFO() and CINFO() log an informational message. If logging is enabled and not masked the provided message will always be logged.

CNDBG() CDBG() log a debug message. Both CLOG_F_ENABLED and CLOG_F_DBGENABLE must be set for the message to be logged.

CNWARNX() CWARNX() CNWARN() CWARN() are functionally equivalent to the warn(3) functions. The functions with an X in their name suppress strerror(3) output.

CNFATALX() CFATALX() CNFATAL() CFATAL() are functionally equivalent to the err(3) functions. The functions with an X in their name suppress strerror(3) output. These functions will terminate the program using exit(3) with a return value of 1.

CNABORTX() CABORTX() CNABORT() CABORT() are functionally similar to the err(3) functions. The functions with an X in their name suppress strerror(3) output. These functions will terminate the program using abort(3).

SEE ALSO
printf(3) ctime(3) syslog(3) err(3)

HISTORY
-nosplit clog was written by Marco Peereboom <marco@peereboom.us>