2 * mono-log-windows.c: Simplistic simulation of a syslog logger for Windows
4 * This module contains the Windows syslog logger interface
7 * Neale Ferguson <neale@sinenomine.net>
26 #include "mono-logger-internals.h"
28 static FILE *logFile = NULL;
29 static void *logUserData = NULL;
30 static wchar_t *logFileName = L".//mono.log";
35 * @level - GLogLevelFlags value
36 * @returns The equivalent character identifier
39 mapLogFileLevel(GLogLevelFlags level)
41 if (level & G_LOG_LEVEL_ERROR)
43 if (level & G_LOG_LEVEL_CRITICAL)
45 if (level & G_LOG_LEVEL_WARNING)
47 if (level & G_LOG_LEVEL_MESSAGE)
49 if (level & G_LOG_LEVEL_INFO)
51 if (level & G_LOG_LEVEL_DEBUG)
57 * mono_log_open_syslog
59 * Open the syslog file. If the open fails issue a warning and
60 * use stdout as the log file destination.
62 * @ident - Identifier: ignored
63 * @userData - Not used
66 mono_log_open_syslog(const char *ident, void *userData)
68 logFile = _wfopen(logFileName, L"w");
69 if (logFile == NULL) {
70 g_warning("opening of log file %s failed with %s",
74 logUserData = userData;
78 * mono_log_write_syslog
80 * Write data to the syslog file.
82 * @domain - Identifier string
83 * @level - Logging level flags
84 * @format - Printf format string
85 * @vargs - Variable argument list
88 mono_log_write_syslog(const char *domain, GLogLevelFlags level, mono_bool hdr, const char *message)
101 strftime(logTime, sizeof(logTime), "%F %T", tod);
103 fprintf (logFile, "%s level[%c] mono[%d]: %s\n", logTime, mapLogFileLevel (level), pid, message);
107 if (level == G_LOG_FLAG_FATAL)
112 * mono_log_close_syslog
114 * Close the syslog file
117 mono_log_close_syslog()