aboutsummaryrefslogtreecommitdiffstats
path: root/src/LogBackend.cxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/LogBackend.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/LogBackend.cxx b/src/LogBackend.cxx
index a5c0a691f..bddf8db16 100644
--- a/src/LogBackend.cxx
+++ b/src/LogBackend.cxx
@@ -23,18 +23,24 @@
#include "util/Domain.hxx"
#include "util/CharUtil.hxx"
+#ifdef HAVE_GLIB
#include <glib.h>
+#endif
#include <assert.h>
#include <stdio.h>
#include <string.h>
+#include <time.h>
#ifdef HAVE_SYSLOG
#include <syslog.h>
#endif
static LogLevel log_threshold = LogLevel::INFO;
+
+#ifdef HAVE_GLIB
static const char *log_charset;
+#endif
static bool enable_timestamp;
@@ -48,12 +54,16 @@ SetLogThreshold(LogLevel _threshold)
log_threshold = _threshold;
}
+#ifdef HAVE_GLIB
+
void
SetLogCharset(const char *_charset)
{
log_charset = _charset;
}
+#endif
+
void
EnableLogTimestamp()
{
@@ -142,6 +152,7 @@ LogFinishSysLog()
static void
FileLog(const Domain &domain, const char *message)
{
+#ifdef HAVE_GLIB
char *converted;
if (log_charset != nullptr) {
@@ -153,13 +164,16 @@ FileLog(const Domain &domain, const char *message)
message = converted;
} else
converted = nullptr;
+#endif
fprintf(stderr, "%s%s: %.*s\n",
enable_timestamp ? log_date() : "",
domain.GetName(),
chomp_length(message), message);
+#ifdef HAVE_GLIB
g_free(converted);
+#endif
}
void