#include "conf.h"
#include "logging.h"
+#include "memory.h"
#include "util.h"
/* This is used by DEBUG_LOG macro */
static struct LogFile logfiles[MAX_FILELOGS];
+/* Global prefix for debug messages */
+static char *debug_prefix;
+
/* ================================================== */
/* Init function */
void
LOG_Initialise(void)
{
+ debug_prefix = Strdup("");
initialised = 1;
LOG_OpenFileLog(NULL);
}
LOG_CycleLogFiles();
+ Free(debug_prefix);
+
initialised = 0;
}
time_t t;
struct tm *tm;
+ assert(initialised);
+
if (!system_log && file_log && severity >= log_min_severity) {
/* Don't clutter up syslog with timestamps and internal debugging info */
time(&t);
}
#if DEBUG > 0
if (log_min_severity <= LOGS_DEBUG)
- fprintf(file_log, "%s:%d:(%s) ", filename, line_number, function_name);
+ fprintf(file_log, "%s%s:%d:(%s) ", debug_prefix, filename, line_number, function_name);
#endif
}
/* ================================================== */
+LOG_Severity
+LOG_GetMinSeverity(void)
+{
+ return log_min_severity;
+}
+
+/* ================================================== */
+
+void
+LOG_SetDebugPrefix(const char *prefix)
+{
+ Free(debug_prefix);
+ debug_prefix = Strdup(prefix);
+}
+
+/* ================================================== */
+
void
LOG_SetParentFd(int fd)
{
prefixed with the filename, line number, and function name. */
extern void LOG_SetMinSeverity(LOG_Severity severity);
+/* Get the minimum severity */
+extern LOG_Severity LOG_GetMinSeverity(void);
+
+/* Set a prefix for debug messages */
+extern void LOG_SetDebugPrefix(const char *prefix);
+
/* Log messages to a file instead of stderr, or stderr again if NULL */
extern void LOG_OpenFileLog(const char *log_file);