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"
29 #include "mono-time.h"
31 static FILE *logFile
= NULL
;
32 static void *logUserData
= NULL
;
33 static const wchar_t *logFileName
= L
".//mono.log"; // FIXME double slash
38 * @level - GLogLevelFlags value
39 * @returns The equivalent character identifier
42 mapLogFileLevel(GLogLevelFlags level
)
44 if (level
& G_LOG_LEVEL_ERROR
)
46 if (level
& G_LOG_LEVEL_CRITICAL
)
48 if (level
& G_LOG_LEVEL_WARNING
)
50 if (level
& G_LOG_LEVEL_MESSAGE
)
52 if (level
& G_LOG_LEVEL_INFO
)
54 if (level
& G_LOG_LEVEL_DEBUG
)
60 * mono_log_open_syslog:
61 * \param ident Identifier: ignored
62 * \param userData Not used
63 * Open the syslog file. If the open fails issue a warning and
64 * use stdout as the log file destination.
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
80 * \param domain Identifier string
81 * \param level Logging level flags
82 * \param format \c printf format string
83 * \param vargs Variable argument list
84 * Write data to the syslog file.
87 mono_log_write_syslog(const char *domain
, GLogLevelFlags level
, mono_bool hdr
, const char *message
)
99 pid
= mono_process_current_pid ();
100 strftime(logTime
, sizeof(logTime
), MONO_STRFTIME_F
" " MONO_STRFTIME_T
, tod
);
102 fprintf (logFile
, "%s level[%c] mono[%d]: %s\n", logTime
, mapLogFileLevel (level
), pid
, message
);
106 if (level
& G_LOG_LEVEL_ERROR
)
111 * mono_log_close_syslog
113 * Close the syslog file
116 mono_log_close_syslog()