diff -r 62f1a55535e7 -r 0b33b9396851 ucx/logging.c --- a/ucx/logging.c Mon Feb 04 14:46:11 2019 +0100 +++ b/ucx/logging.c Mon Feb 04 17:49:50 2019 +0100 @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright 2016 Olaf Wintermann. All rights reserved. + * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -26,7 +26,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "logging.h" +#include "ucx/logging.h" + #include #include #include @@ -49,6 +50,8 @@ ucx_map_int_put(logger->levels, l, (void*) "[WARNING]"); l = UCX_LOGGER_INFO; ucx_map_int_put(logger->levels, l, (void*) "[INFO]"); + l = UCX_LOGGER_DEBUG; + ucx_map_int_put(logger->levels, l, (void*) "[DEBUG]"); l = UCX_LOGGER_TRACE; ucx_map_int_put(logger->levels, l, (void*) "[TRACE]"); } @@ -68,12 +71,15 @@ const unsigned int line, const char *format, ...) { if (level <= logger->level) { char msg[UCX_LOGGER_MSGMAX]; - char *text; + const char *text; size_t k = 0; size_t n; if ((logger->mask & UCX_LOGGER_LEVEL) > 0) { - text = (char*) ucx_map_int_get(logger->levels, level); + text = (const char*) ucx_map_int_get(logger->levels, level); + if (!text) { + text = "[UNKNOWN]"; + } n = strlen(text); n = n > 256 ? 256 : n; memcpy(msg+k, text, n); @@ -91,7 +97,9 @@ k += sprintf(msg+k, ":%u ", line); } - msg[k++] = '-'; msg[k++] = ' '; + if (k > 0) { + msg[k++] = '-'; msg[k++] = ' '; + } va_list args; va_start (args, format);