From 55c16d0d0f47ff0ad4c9baab77aaad80e7d203c7 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sat, 25 Aug 2012 18:37:47 +0200 Subject: [PATCH] Adjust the default logformat. The file, line and function information is now only printed for error and debug messages. --- examples/common.c | 6 +++++- src/context.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/common.c b/examples/common.c index 1f1ea3d..f69e7e4 100644 --- a/examples/common.c +++ b/examples/common.c @@ -58,5 +58,9 @@ logfunc (dc_context_t *context, dc_loglevel_t loglevel, const char *file, unsign { const char *loglevels[] = {"NONE", "ERROR", "WARNING", "INFO", "DEBUG", "ALL"}; - message ("%s: %s [in %s:%d (%s)]\n", loglevels[loglevel], msg, file, line, function); + if (loglevel == DC_LOGLEVEL_ERROR || loglevel == DC_LOGLEVEL_WARNING) { + message ("%s: %s [in %s:%d (%s)]\n", loglevels[loglevel], msg, file, line, function); + } else { + message ("%s: %s\n", loglevels[loglevel], msg); + } } diff --git a/src/context.c b/src/context.c index 26f9737..a0cf839 100644 --- a/src/context.c +++ b/src/context.c @@ -126,7 +126,11 @@ logfunc (dc_context_t *context, dc_loglevel_t loglevel, const char *file, unsign { const char *loglevels[] = {"NONE", "ERROR", "WARNING", "INFO", "DEBUG", "ALL"}; - fprintf (stderr, "%s: %s [in %s:%d (%s)]\n", loglevels[loglevel], msg, file, line, function); + if (loglevel == DC_LOGLEVEL_ERROR || loglevel == DC_LOGLEVEL_WARNING) { + fprintf (stderr, "%s: %s [in %s:%d (%s)]\n", loglevels[loglevel], msg, file, line, function); + } else { + fprintf (stderr, "%s: %s\n", loglevels[loglevel], msg); + } } #endif