#include <stdio.h>
#include <time.h>
#include <common-types.h>
Go to the source code of this file.
Data Structures | |
struct | DCLog |
Defines | |
#define | DCLOG_ALARM 0 |
alarms | |
#define | DCLOG_ERROR 1 |
error messages | |
#define | DCLOG_WARNING 2 |
warnings | |
#define | DCLOG_INFO 3 |
information messages | |
#define | DCLOG_DEBUG 4 |
debugging messages | |
#define | DCLOG_PROFILE 5 |
profiling messages | |
#define | DCLOG_FN_LEN 1024 |
Length of our filename string. | |
#define | DCLOG_TS_FMT_LEN 32 |
Length of our timestamp strfime format string. | |
#define | DCLOG_TS_FMT_DEFAULT ".%d" |
Default timestamp strfime format string. | |
#define | DCLOG_MAX_ALARM_SIZE 4096 |
Maximum size of an alarm email. | |
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 | DCLogAlarm (DCLog *dclog, const char *code, const char *syn, const char *fmt,...) |
UCHAR | DCLogWrite (DCLog *dclog, const UCHAR lev, const char *fmt,...) |
UCHAR | DCLogCanLog (const DCLog *dclog) |
UCHAR | DCLogSmtpSend (const char *mailhost, const char *to, const char *from, const char *subject, const char *msg) |
UCHAR | DCLogSmtpShutdown (const int socket, const int retval) |
|
alarms
|
|
debugging messages
|
|
error messages
|
|
Length of our filename string.
|
|
information messages
|
|
Maximum size of an alarm email.
|
|
profiling messages
|
|
Default timestamp strfime format string.
|
|
Length of our timestamp strfime format string.
|
|
warnings
|
|
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.
|