Add support for debug messages

Add new DEBUG_LOG macro for debug messages. The messages are enabled
when compiled with --enable-debug and they are printed when the -d
option is used twice.
This commit is contained in:
Miroslav Lichvar
2013-11-26 18:53:10 +01:00
parent 0731cd6950
commit 4bbc5520b8
6 changed files with 42 additions and 5 deletions

View File

@@ -42,6 +42,8 @@ static int system_log = 0;
static int parent_fd = 0;
static int log_debug = 0;
static time_t last_limited = 0;
#ifdef WINNT
@@ -108,6 +110,9 @@ static void log_message(int fatal, LOG_Severity severity, const char *message)
if (system_log) {
int priority;
switch (severity) {
case LOGS_DEBUG:
priority = LOG_DEBUG;
break;
case LOGS_INFO:
priority = LOG_INFO;
break;
@@ -141,6 +146,10 @@ void LOG_Message(LOG_Severity severity, LOG_Facility facility,
time_t t;
struct tm stm;
/* Don't write debug messages if not enabled */
if (!log_debug && severity == LOGS_DEBUG)
return;
#ifdef WINNT
#else
if (!system_log) {
@@ -157,6 +166,7 @@ void LOG_Message(LOG_Severity severity, LOG_Facility facility,
va_end(other_args);
switch (severity) {
case LOGS_DEBUG:
case LOGS_INFO:
case LOGS_WARN:
case LOGS_ERR:
@@ -192,6 +202,13 @@ LOG_OpenSystemLog(void)
/* ================================================== */
void LOG_EnableDebug(void)
{
log_debug = 1;
}
/* ================================================== */
void
LOG_SetParentFd(int fd)
{