#else
#include <process.h>
#endif
-#include "mono-logger.h"
+#include "mono-logger-internals.h"
static FILE *logFile = NULL;
static void *logUserData = NULL;
if (path == NULL) {
logFile = stdout;
} else {
+#ifndef HOST_WIN32
logFile = fopen(path, "w");
+#else
+ gunichar2 *wPath = g_utf8_to_utf16(path, -1, 0, 0, 0);
+ if (wPath != NULL) {
+ logFile = _wfopen((wchar_t *) wPath, L"w");
+ g_free (wPath);
+ }
+#endif
if (logFile == NULL) {
g_warning("opening of log file %s failed with %s - defaulting to stdout",
path, strerror(errno));
+ logFile = stdout;
}
}
logUserData = userData;
* @vargs - Variable argument list
*/
void
-mono_log_write_logfile(const char *domain, GLogLevelFlags level, mono_bool hdr, const char *format, va_list args)
+mono_log_write_logfile (const char *log_domain, GLogLevelFlags level, mono_bool hdr, const char *message)
{
time_t t;
- char logTime[80],
- logMessage[512];
- pid_t pid;
- int iLog = 0;
- size_t nLog;
if (logFile == NULL)
logFile = stdout;
if (hdr) {
+ pid_t pid;
+ char logTime [80];
+
#ifndef HOST_WIN32
struct tm tod;
time(&t);
localtime_r(&t, &tod);
pid = getpid();
- strftime(logTime, sizeof(logTime), "%F %T", &tod);
+ strftime(logTime, sizeof(logTime), "%Y-%m-%d %H:%M:%S", &tod);
#else
struct tm *tod;
time(&t);
pid = _getpid();
strftime(logTime, sizeof(logTime), "%F %T", tod);
#endif
- iLog = snprintf(logMessage, sizeof(logMessage), "%s level[%c] mono[%d]: ",
- logTime,mapLogFileLevel(level),pid);
+ fprintf (logFile, "%s level[%c] mono[%d]: %s\n", logTime, mapLogFileLevel (level), pid, message);
+ } else {
+ fprintf (logFile, "%s%s%s\n",
+ log_domain != NULL ? log_domain : "",
+ log_domain != NULL ? ": " : "",
+ message);
}
- nLog = sizeof(logMessage) - iLog - 2;
- iLog = vsnprintf(logMessage+iLog, nLog, format, args);
-#ifdef HOST_WIN32
- logMessage[iLog++] = '\r';
-#endif
- logMessage[iLog++] = '\n';
- logMessage[iLog++] = '\0';
- fputs(logMessage, logFile);
+
fflush(logFile);
if (level == G_LOG_FLAG_FATAL)