#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <netinet/in.h>
#include <dclog.h>
Defines | |
#define | DCLOG_FEAT_HEADER 1 << 0 |
see DCLogSetHeader() | |
#define | DCLOG_FEAT_UNIQUE 1 << 1 |
see DCLogSetUniqueByDay() | |
#define | DCLOG_FEAT_PLEVEL 1 << 2 |
see DCLogSetPrintLevel() | |
Functions | |
DCLog * | NewDCLog (void) |
UCHAR | DestroyDCLog (DCLog *dclog) |
char | DCLogLevelToNum (const char *str) |
const char * | DCLogLevelToString (const char lev) |
UCHAR | DCLogSetHeader (DCLog *dclog, const UCHAR val) |
UCHAR | DCLogSetLevel (DCLog *dclog, const UCHAR lev) |
UCHAR | DCLogSetMailServer (DCLog *dclog, const char *mailhost) |
UCHAR | DCLogSetMaxFileSize (DCLog *dclog, const int size) |
UCHAR | DCLogSetPageServer (DCLog *dclog, const char *server) |
UCHAR | DCLogSetPrintLevel (DCLog *dclog, const UCHAR val) |
UCHAR | DCLogSetProgram (DCLog *dclog, const char *prog) |
UCHAR | DCLogSetSpool (DCLog *dclog, const char *spool) |
UCHAR | DCLogSetUniqueByDay (DCLog *dclog, const UCHAR val) |
UCHAR | DCLogSetTimestampFormat (DCLog *dclog, char *const ts_fmt) |
UCHAR | DCLogOpen (DCLog *dclog, const char *fn, const char *mode) |
UCHAR | DCLogClose (DCLog *dclog) |
UCHAR | DCLogWrite (DCLog *dclog, const UCHAR lev, const char *fmt,...) |
UCHAR | DCLogAlarm (DCLog *dclog, const char *code, const char *syn, const char *fmt,...) |
UCHAR | DCLogCanLog (const DCLog *dclog) |
|
see DCLogSetHeader()
|
|
|
|
|
|
Sends an alarm. Forks a child process, calls the function specified by the fp function pointer argument (if fp is NULL, no function is called), connects to the SMTP mail server (which should have been set by DCLogSetMailServer()), and sends an alarm email of the following format: From: [program, set by DCLogSetProgram()]@[hostname]. To: [page server, set by DCLogSetPageServer()]. Subject: [code] : [syn]. Body: [controlled by format string fmt].
|
|
Makes sure the object is able to log.
|
|
Closes an open logfile.
|
|
Returns the numeric log level for the specified string representation.
|
|
Returns the string representation of the specified numeric log level.
|
|
Opens a logfile. If the unique_by_day member of the DCLog object is set to true, the day of the month will be appended to the filename of the logfile (see DCLogSetUniqueByDay, above).
|
|
Turns the log header on or off. If on, each log message will be appended to the timestamp and process ID (e.g. 15:27:13.05 [2727]: test for echo).
|
|
Sets the logging level.
|
|
Sets the hostname of the SMTP mail server. Alarm emails will be sent through this mail server.
|
|
Sets maximum file size and turns on size limits.
|
|
Sets the page server's email address. Alarm emails will be sent to this address.
|
|
Turns printing the message level on or off. If on, each log message will be appended to the mnemonic level at which it was logged (e.g. messages logged at DCLOG_DEBUG would look like: "DEBUG some message or other").
|
|
Sets the program name that will be used when alarming. The from address in the alarm email will be program_name, where program_name is set by this function, and hostname is the hostname of the machine on which your code is running.
|
|
Sets the alarm spool directory.
|
|
Sets the timestamp format string and turns the unique feature on
|
|
Turns unique logfiles on or off. If on, each logfile will get the day of the month appended to it (e.g. my_logfile.27 versus my_logfile). Setting this after the logfile is opened does not make a whole lot of sense.
|
|
Writes a message to an open logfile at the specified level. If the global logging level for this object is lower than the specified level, the mesage will not be logged, but success will be returned. If the ts_header member of the DCLog object is set to true, a timestamp / PID header will be written before every log message (see DCLogSetHeader(), above). No newline is appended to your message, so if you want one, put it in your format string. If the level is zero, "ERROR: " will be written before the message.
|
|
Destroys a log object that is no longer needed.
|
|
Constructer; creates a new DCLog object.
|