summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2019-11-20 04:00:29 +0100
committerlaforge <laforge@osmocom.org>2019-11-23 07:58:47 +0000
commitf2644aee5525a6f889816c3e0d613e3c7145d01d (patch)
treed940f9955612690ad3be2e805d5b8ddf08b45223 /src
parenta981f9dfd4e9305b627e552aeecdabe8a4ca486a (diff)
logging.h: define ansi color constants
It's hard to figure out what color logging categories have with those ANSI color code strings. Instead, define these OSMO_LOGCOLOR_* constants. Naming: commonly, the logging.h header has the "LOG" prefix in the name, but it seems saner to include the OSMO_ prefix: it seems too likely that some libosmocore user somewhere already has defined "LOGCOLOR_RED" somewhere. Change-Id: I03b6b1f73ae7ee61d37ff921e071a3d0881d3e9a
Diffstat (limited to 'src')
-rw-r--r--src/logging.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/logging.c b/src/logging.c
index b030f8a6..7baa7778 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -344,11 +344,11 @@ static const char* color(int subsys)
}
static const struct value_string level_colors[] = {
- { LOGL_DEBUG, "\033[1;34m" },
- { LOGL_INFO, "\033[1;32m" },
- { LOGL_NOTICE, "\033[1;33m" },
- { LOGL_ERROR, "\033[1;31m" },
- { LOGL_FATAL, "\033[1;31m" },
+ { LOGL_DEBUG, OSMO_LOGCOLOR_BLUE },
+ { LOGL_INFO, OSMO_LOGCOLOR_GREEN },
+ { LOGL_NOTICE, OSMO_LOGCOLOR_YELLOW },
+ { LOGL_ERROR, OSMO_LOGCOLOR_RED },
+ { LOGL_FATAL, OSMO_LOGCOLOR_RED },
{ 0, NULL }
};
@@ -428,7 +428,7 @@ static void _output(struct log_target *target, unsigned int subsys,
ret = snprintf(buf + offset, rem, "%s%s%s%s ",
target->use_color ? level_color(level) : "",
log_category_name(subsys),
- target->use_color ? "\033[0;m" : "",
+ target->use_color ? OSMO_LOGCOLOR_END : "",
c_subsys ? c_subsys : "");
if (ret < 0)
goto err;
@@ -438,7 +438,7 @@ static void _output(struct log_target *target, unsigned int subsys,
ret = snprintf(buf + offset, rem, "%s%s%s%s ",
target->use_color ? level_color(level) : "",
log_level_str(level),
- target->use_color ? "\033[0;m" : "",
+ target->use_color ? OSMO_LOGCOLOR_END : "",
c_subsys ? c_subsys : "");
if (ret < 0)
goto err;
@@ -501,7 +501,7 @@ static void _output(struct log_target *target, unsigned int subsys,
}
if (target->use_color) {
- ret = snprintf(buf + offset, rem, "\033[0;m");
+ ret = snprintf(buf + offset, rem, OSMO_LOGCOLOR_END);
if (ret < 0)
goto err;
OSMO_SNPRINTF_RET(ret, rem, offset, len);