#include "dnxLogging.h"
#include "dnxError.h"
#include "dnxTransport.h"
#include "dnxDebug.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <syslog.h>
Go to the source code of this file.
Defines | |
#define | LOCALSTATEDIR "/var" |
#define | LOGDIR LOCALSTATEDIR "/log" |
#define | DEF_LOG_FILE LOGDIR "/dnx.log" |
#define | DEF_DEBUG_FILE LOGDIR "/dnx.debug.log" |
#define | DEF_DEBUG_LEVEL 0 |
#define | MAX_LOG_LINE 4096 |
Maximum log line length. | |
#define | SYSLOG_IDENT "DNX" |
The openlog ident string. | |
Functions | |
static int | decodeSyslogFlags (const char *flagstr, int defaultSev) |
Decode the syslog flags specified in a comma delimited string. | |
static FILE * | openFile (const char *filename, int *pstd) |
Open a file by name, or use standard handles. | |
static void | dnx_vsyslog (int pri, const char *fmt, va_list ap) |
A version if vsyslog that calls the system version or implements. | |
static int | vlogger (FILE *fp, char *fmt, va_list ap) |
A variable argument logger function that takes a stream. | |
void | dnxLog (char *fmt,...) |
Log a parameterized message to the dnx system log file. | |
void | dnxDebug (int level, char *fmt,...) |
Log a parameterized message to the dnx DEBUG log. | |
int | dnxAudit (char *fmt,...) |
Log a parameterized message to the global audit log file. | |
void | dnxLogInit (char *logFile, char *debugFile, char *auditFile, int *debugLevel) |
Initialize the logging sub-system with global references. | |
Variables | |
static char | SLTAG [] = "syslog:" |
the syslog prefix tag. | |
static int | defDebugLevel = DEF_DEBUG_LEVEL |
The default debug level. | |
static int | s_syslogLog = 0 |
syslog used for logging | |
static int | s_syslogDebug = 0 |
syslog used for debug | |
static int | s_syslogAudit = 0 |
syslog used for audit | |
static int * | s_debugLevel = &defDebugLevel |
Debug level pointer. | |
static char | s_logFileName [FILENAME_MAX+1] = DEF_LOG_FILE |
static char | s_dbgFileName [FILENAME_MAX+1] = DEF_DEBUG_FILE |
static char | s_audFileName [FILENAME_MAX+1] = "" |
Definition in file dnxLogging.c.
#define DEF_DEBUG_FILE LOGDIR "/dnx.debug.log" |
Definition at line 59 of file dnxLogging.c.
#define DEF_DEBUG_LEVEL 0 |
Definition at line 63 of file dnxLogging.c.
#define DEF_LOG_FILE LOGDIR "/dnx.log" |
Definition at line 55 of file dnxLogging.c.
#define LOCALSTATEDIR "/var" |
Definition at line 49 of file dnxLogging.c.
#define LOGDIR LOCALSTATEDIR "/log" |
Definition at line 52 of file dnxLogging.c.
#define MAX_LOG_LINE 4096 |
#define SYSLOG_IDENT "DNX" |
static int decodeSyslogFlags | ( | const char * | flagstr, | |
int | defaultSev | |||
) | [static] |
Decode the syslog flags specified in a comma delimited string.
[in] | flagstr | - a comma-delimited string containing syslog flags |
[in] | defaultSev | - the default severity level to use if none is given in the flagstr parameter. |
Definition at line 93 of file dnxLogging.c.
Referenced by dnxLogInit().
static void dnx_vsyslog | ( | int | pri, | |
const char * | fmt, | |||
va_list | ap | |||
) | [static] |
A version if vsyslog that calls the system version or implements.
[in] | pri | - the syslog priority value. |
[in] | fmt | - the syslog format string. |
[in] | ap | - the syslog variable argument array. |
Definition at line 212 of file dnxLogging.c.
References MAX_LOG_LINE.
Referenced by dnxAudit(), dnxDebug(), and dnxLog().
int dnxAudit | ( | char * | fmt, | |
... | ||||
) |
Log a parameterized message to the global audit log file.
Returns quickly if auditing is disabled because a null or empty log file was specified on startup.
[in] | fmt | - a format specifier string similar to that of printf. |
Definition at line 328 of file dnxLogging.c.
References dnx_vsyslog(), openFile(), s_audFileName, s_syslogAudit, and vlogger().
Referenced by dnxAuditJob().
void dnxDebug | ( | int | level, | |
char * | fmt, | |||
... | ||||
) |
Log a parameterized message to the dnx DEBUG log.
This routine logs a debug message if the current global (configured) debug level is greater than or equal the value of level
.
[in] | level | - the debug level at which to log the message. |
[in] | fmt | - a format specifier string similar to that of printf. |
Definition at line 296 of file dnxLogging.c.
References dnx_vsyslog(), openFile(), s_dbgFileName, s_debugLevel, s_syslogDebug, and vlogger().
Referenced by AllocateNodeRequest(), cleanThreadPool(), dnxAgentServer(), dnxCheckHeap(), dnxCollector(), dnxFree(), dnxGetNodeRequest(), dnxJobListAdd(), dnxJobListCollect(), dnxJobListDispatch(), dnxMalloc(), dnxPluginExecute(), dnxPostNewJob(), dnxPostResult(), dnxRegisterNode(), dnxSendJob(), dnxSendJobMsg(), dnxSendMgmtReply(), dnxSendMgmtRequest(), dnxSendNodeRequest(), dnxSendResult(), dnxTimer(), dnxUdpRead(), dnxUdpWrite(), dnxWaitForJob(), dnxWaitForMgmtReply(), dnxWaitForMgmtRequest(), dnxWaitForNodeRequest(), dnxWaitForResult(), dnxWlmDestroy(), dnxWorker(), dnxWorkerCleanup(), dnxXmlUnescapeStr(), dump_block(), ehProcessData(), ehSvcCheck(), GetAckNak(), GetMsgHeader(), main(), processCommands(), ProcessJobTransferMsg(), processRequests(), ProcessResultTransferMsg(), SendMsgResponse(), and TransferJobToServer().
void dnxLog | ( | char * | fmt, | |
... | ||||
) |
Log a parameterized message to the dnx system log file.
[in] | fmt | - a format specifier string similar to that of printf. |
Definition at line 264 of file dnxLogging.c.
References dnx_vsyslog(), openFile(), s_logFileName, s_syslogLog, and vlogger().
Referenced by createPidFile(), daemonize(), dnxAgentServer(), dnxCalculateJobListSize(), dnxCfgParserParse(), dnxCollector(), dnxCollectorCreate(), dnxDispatcher(), dnxDispatcherCreate(), dnxInitAgent(), dnxJobListAdd(), dnxPluginDeInit(), dnxPluginInit(), dnxPostNewJob(), dnxReconfigure(), dnxRegisterNode(), dnxRegistrar(), dnxRegistrarCreate(), dnxResultsListener(), dnxSendJobMsg(), dnxServerInit(), dnxTcpOpen(), dnxTcpRead(), dnxTcpWrite(), dnxTimer(), dnxTimerCreate(), dnxUdpOpen(), dnxUdpRead(), dnxUdpWrite(), dnxWlmCreate(), dnxWlmDestroy(), dnxWorker(), dropPrivileges(), ehProcessData(), ehSvcCheck(), growThreadPool(), initClientComm(), initWorkerComm(), launchScript(), logConfigChanges(), logGblConfigChanges(), main(), nebmodule_deinit(), nebmodule_init(), processCommands(), processRequests(), ProcessResultTransferMsg(), validateCfg(), and workerCreate().
void dnxLogInit | ( | char * | logFile, | |
char * | debugFile, | |||
char * | auditFile, | |||
int * | debugLevel | |||
) |
Initialize the logging sub-system with global references.
System and debug logging defaults to STDOUT. Both "STDOUT" and "STDERR" may be specified as log file strings for the log, debug and audit file paths. The audit log is optional, and is disabled if auditFile
is null or empty.
The address of the debug flag is passed so it can change the behavior of the logging system dynamically.
[in] | logFile | - the global log file path. |
[in] | debugFile | - the global debug file path. |
[in] | auditFile | - the global audit file path (optional). |
[in] | debugLevel | - the address of the global debug level indicator. |
Definition at line 362 of file dnxLogging.c.
References decodeSyslogFlags(), s_audFileName, s_dbgFileName, s_debugLevel, s_logFileName, s_syslogAudit, s_syslogDebug, s_syslogLog, SLTAG, and SYSLOG_IDENT.
Referenced by main(), and nebmodule_init().
static FILE* openFile | ( | const char * | filename, | |
int * | pstd | |||
) | [static] |
Open a file by name, or use standard handles.
[in] | filename | - the name of the file to be opened. |
[out] | pstd | - storage for returned "standard handle" flag |
Definition at line 182 of file dnxLogging.c.
Referenced by dnxAudit(), dnxDebug(), and dnxLog().
static int vlogger | ( | FILE * | fp, | |
char * | fmt, | |||
va_list | ap | |||
) | [static] |
A variable argument logger function that takes a stream.
[in] | fp | - the stream to write to. |
[in] | fmt | - the format string to write. |
[in] | ap | - the argument list to use. |
Definition at line 235 of file dnxLogging.c.
Referenced by dnxAudit(), dnxDebug(), and dnxLog().
int defDebugLevel = DEF_DEBUG_LEVEL [static] |
char s_audFileName[FILENAME_MAX+1] = "" [static] |
char s_dbgFileName[FILENAME_MAX+1] = DEF_DEBUG_FILE [static] |
int* s_debugLevel = &defDebugLevel [static] |
Debug level pointer.
Definition at line 76 of file dnxLogging.c.
Referenced by dnxDebug(), and dnxLogInit().
char s_logFileName[FILENAME_MAX+1] = DEF_LOG_FILE [static] |
int s_syslogAudit = 0 [static] |
syslog used for audit
Definition at line 75 of file dnxLogging.c.
Referenced by dnxAudit(), and dnxLogInit().
int s_syslogDebug = 0 [static] |
syslog used for debug
Definition at line 74 of file dnxLogging.c.
Referenced by dnxDebug(), and dnxLogInit().
int s_syslogLog = 0 [static] |
syslog used for logging
Definition at line 73 of file dnxLogging.c.
Referenced by dnxLog(), and dnxLogInit().
char SLTAG[] = "syslog:" [static] |