diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2017-08-13 20:45:03 +0200 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2017-08-13 20:45:03 +0200 |
commit | 34a630a3e057e3ed57ce759c856f4a344176cad8 (patch) | |
tree | 3d77c128f517519904c57f38bdc44907bd422b32 | |
parent | 335c2197c16b1d36d3549c9614b52df5c2545397 (diff) | |
download | embedlog-34a630a3e057e3ed57ce759c856f4a344176cad8.tar.gz embedlog-34a630a3e057e3ed57ce759c856f4a344176cad8.tar.bz2 embedlog-34a630a3e057e3ed57ce759c856f4a344176cad8.zip |
Added possibility to remove log level from print
-rw-r--r-- | include/embedlog.h | 9 | ||||
-rw-r--r-- | src/el-print.c | 5 | ||||
-rw-r--r-- | src/options.c | 23 |
3 files changed, 33 insertions, 4 deletions
diff --git a/include/embedlog.h b/include/embedlog.h index fcb3231..08cf44f 100644 --- a/include/embedlog.h +++ b/include/embedlog.h @@ -40,8 +40,9 @@ enum el_option EL_OPT_COLORS, EL_OPT_TS, EL_OPT_TS_TM, - + EL_OPT_PRINT_LEVEL, EL_OPT_FINFO, + EL_OPT_FNAME, EL_OPT_FROTATE_NUMBER, EL_OPT_FROTATE_SIZE, @@ -51,9 +52,9 @@ enum el_option enum el_option_timestamp { + EL_OPT_TS_OFF, EL_OPT_TS_LONG, - EL_OPT_TS_SHORT, - EL_OPT_TS_OFF + EL_OPT_TS_SHORT }; enum el_option_timestamp_timer @@ -71,6 +72,7 @@ struct el_options int colors; int timestamp; int timestamp_timer; + int print_log_level; int finfo; int frotate_number; @@ -81,6 +83,7 @@ struct el_options const char *fname; }; +int el_init(void); int el_options_init(struct el_options *); int el_level_set(enum el_level); int el_olevel_set(struct el_options *, enum el_level); diff --git a/src/el-print.c b/src/el-print.c index 3e94b49..7a629f6 100644 --- a/src/el-print.c +++ b/src/el-print.c @@ -555,7 +555,10 @@ int el_voprint ++w; } - w += sprintf(buf + w, "%c/", char_level[level]); + if (options->print_log_level) + { + w += sprintf(buf + w, "%c/", char_level[level]); + } /* * add requested log from format, we add + 1 to include null termination diff --git a/src/options.c b/src/options.c index e74affb..16e4078 100644 --- a/src/options.c +++ b/src/options.c @@ -148,6 +148,13 @@ static int el_vooption switch (option) { + case EL_OPT_PRINT_LEVEL: + value_int = va_arg(ap, int); + VALID(EINVAL, (value_int & ~1) == 0); + + options->print_log_level = value_int; + return 0; + #if ENABLE_COLORS case EL_OPT_COLORS: @@ -242,6 +249,17 @@ static int el_vooption /* ========================================================================== + initializes global options to default state + ========================================================================== */ + + +int el_init(void) +{ + return el_options_init(&g_options); +} + + +/* ========================================================================== Sets options object to sane values errno @@ -257,6 +275,11 @@ int el_options_init VALID(EINVAL, options); memset(options, 0, sizeof(*options)); + options->print_log_level = 1; +#if ENABLE_OUT_STDERR + options->outputs = EL_OUT_STDERR; +#endif + return 0; } |