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"
27 #include "mono-proclib.h"
29 static FILE *logFile = NULL;
30 static void *logUserData = NULL;
31 static wchar_t *logFileName = L".//mono.log";
36 * @level - GLogLevelFlags value
37 * @returns The equivalent character identifier
40 mapLogFileLevel(GLogLevelFlags level)
42 if (level & G_LOG_LEVEL_ERROR)
44 if (level & G_LOG_LEVEL_CRITICAL)
46 if (level & G_LOG_LEVEL_WARNING)
48 if (level & G_LOG_LEVEL_MESSAGE)
50 if (level & G_LOG_LEVEL_INFO)
52 if (level & G_LOG_LEVEL_DEBUG)
58 * mono_log_open_syslog
60 * Open the syslog file. If the open fails issue a warning and
61 * use stdout as the log file destination.
63 * @ident - Identifier: ignored
64 * @userData - Not used
67 mono_log_open_syslog(const char *ident, void *userData)
69 logFile = _wfopen(logFileName, L"w");
70 if (logFile == NULL) {
71 g_warning("opening of log file %s failed with %s",
75 logUserData = userData;
79 * mono_log_write_syslog
81 * Write data to the syslog file.
83 * @domain - Identifier string
84 * @level - Logging level flags
85 * @format - Printf format string
86 * @vargs - Variable argument list
89 mono_log_write_syslog(const char *domain, GLogLevelFlags level, mono_bool hdr, const char *message)
101 pid = mono_process_current_pid ();
102 strftime(logTime, sizeof(logTime), "%F %T", tod);
104 fprintf (logFile, "%s level[%c] mono[%d]: %s\n", logTime, mapLogFileLevel (level), pid, message);
108 if (level & G_LOG_LEVEL_ERROR)
113 * mono_log_close_syslog
115 * Close the syslog file
118 mono_log_close_syslog()