3 * Simplistic simulation of a syslog logger for Windows
5 * This module contains the Windows syslog logger interface
8 * Neale Ferguson <neale@sinenomine.net>
27 #include "mono-logger-internals.h"
28 #include "mono-proclib.h"
30 static FILE *logFile = NULL;
31 static void *logUserData = NULL;
32 static wchar_t *logFileName = L".//mono.log";
37 * @level - GLogLevelFlags value
38 * @returns The equivalent character identifier
41 mapLogFileLevel(GLogLevelFlags level)
43 if (level & G_LOG_LEVEL_ERROR)
45 if (level & G_LOG_LEVEL_CRITICAL)
47 if (level & G_LOG_LEVEL_WARNING)
49 if (level & G_LOG_LEVEL_MESSAGE)
51 if (level & G_LOG_LEVEL_INFO)
53 if (level & G_LOG_LEVEL_DEBUG)
59 * mono_log_open_syslog:
60 * \param ident Identifier: ignored
61 * \param userData Not used
62 * Open the syslog file. If the open fails issue a warning and
63 * use stdout as the log file destination.
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
79 * \param domain Identifier string
80 * \param level Logging level flags
81 * \param format \c printf format string
82 * \param vargs Variable argument list
83 * Write data to the syslog file.
86 mono_log_write_syslog(const char *domain, GLogLevelFlags level, mono_bool hdr, const char *message)
98 pid = mono_process_current_pid ();
99 strftime(logTime, sizeof(logTime), "%F %T", tod);
101 fprintf (logFile, "%s level[%c] mono[%d]: %s\n", logTime, mapLogFileLevel (level), pid, message);
105 if (level & G_LOG_LEVEL_ERROR)
110 * mono_log_close_syslog
112 * Close the syslog file
115 mono_log_close_syslog()