diff options
author | Simon Ser <contact@emersion.fr> | 2020-08-27 15:56:16 +0000 |
---|---|---|
committer | Kenny Levinsen <kl@kl.wtf> | 2020-08-28 01:21:57 +0200 |
commit | 07ceeeebe014374626904e5d7c8a20d1a45453fe (patch) | |
tree | a2e11abccf998199c01d2424f0a19eb85449f8f0 /common/log.c | |
parent | 48b9bf47075271c91097eba4bf8e9316aa33f9c8 (diff) |
Introduce libseat_set_log_level
The default level is SILENT. log_init no longer takes an initial log
level (so that calls to libseat_set_log_level prior to log_init work
correctly).
Diffstat (limited to 'common/log.c')
-rw-r--r-- | common/log.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/common/log.c b/common/log.c index 646480d..bea683b 100644 --- a/common/log.c +++ b/common/log.c @@ -12,7 +12,7 @@ const long NSEC_PER_SEC = 1000000000; static void log_stderr(enum libseat_log_level level, const char *fmt, va_list args); -static enum libseat_log_level current_log_level; +static enum libseat_log_level current_log_level = LIBSEAT_LOG_LEVEL_SILENT; static libseat_log_func current_log_handler = log_stderr; static struct timespec start_time = {-1, -1}; static bool colored = false; @@ -64,12 +64,11 @@ static void log_stderr(enum libseat_log_level level, const char *fmt, va_list ar fprintf(stderr, "%s", postfix); } -void log_init(enum libseat_log_level level) { +void log_init(void) { if (start_time.tv_sec >= 0) { return; } clock_gettime(CLOCK_MONOTONIC, &start_time); - current_log_level = level; colored = isatty(STDERR_FILENO); } @@ -93,3 +92,7 @@ void libseat_set_log_handler(libseat_log_func handler) { } current_log_handler = handler; } + +void libseat_set_log_level(enum libseat_log_level level) { + current_log_level = level; +} |