diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2018-04-05 16:45:04 +0200 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2018-04-05 17:00:04 +0200 |
commit | cfeb28546da0a7e3fe48524815f32411daca985c (patch) | |
tree | ee356ce7292c408651c0d817cce3f90819d8023b | |
parent | 8048fde05ec8122e7d2579705b356cb75f2e80cc (diff) | |
download | embedlog-cfeb28546da0a7e3fe48524815f32411daca985c.tar.gz embedlog-cfeb28546da0a7e3fe48524815f32411daca985c.tar.bz2 embedlog-cfeb28546da0a7e3fe48524815f32411daca985c.zip |
add: shortcut macros for printing with custom options
-rw-r--r-- | examples/print-options.c | 14 | ||||
-rw-r--r-- | include/embedlog.h | 18 |
2 files changed, 32 insertions, 0 deletions
diff --git a/examples/print-options.c b/examples/print-options.c index 68be708..6a0b18f 100644 --- a/examples/print-options.c +++ b/examples/print-options.c @@ -5,8 +5,12 @@ #include "embedlog.h" +#define EL_OPTIONS_OBJECT &opts + int main(void) { + struct el_options opts; + el_init(); el_option(EL_OUT, EL_OUT_STDERR); @@ -62,4 +66,14 @@ int main(void) el_print(ELI, "set prefix to null to disable it"); el_cleanup(); + + + el_oinit(&opts); + el_ooption(&opts, EL_OUT, EL_OUT_STDERR); + el_oprint(ELI, &opts, "you can do same thing as about with custom"); + el_oprint(ELI, &opts, "options object for two or more logger."); + el_oprint(OELE, "and if you define EL_OPTIONS_OBJECT you will be"); + el_oprint(OELF, "able to print messages without passing options"); + el_oprint(OELW, "each time to print functions"); + el_ocleanup(&opts); } diff --git a/include/embedlog.h b/include/embedlog.h index fe3e1bd..1cc72b6 100644 --- a/include/embedlog.h +++ b/include/embedlog.h @@ -24,6 +24,15 @@ extern "C" { # define ELN NULL, 0, EL_NOTICE # define ELI NULL, 0, EL_INFO # define ELD NULL, 0, EL_DBG + +# define OELF NULL, 0, EL_FATAL, EL_OPTIONS_OBJECT +# define OELA NULL, 0, EL_ALERT, EL_OPTIONS_OBJECT +# define OELC NULL, 0, EL_CRIT, EL_OPTIONS_OBJECT +# define OELE NULL, 0, EL_ERROR, EL_OPTIONS_OBJECT +# define OELW NULL, 0, EL_WARN, EL_OPTIONS_OBJECT +# define OELN NULL, 0, EL_NOTICE, EL_OPTIONS_OBJECT +# define OELI NULL, 0, EL_INFO, EL_OPTIONS_OBJECT +# define OELD NULL, 0, EL_DBG, EL_OPTIONS_OBJECT #else # define ELF __FILE__, __LINE__, EL_FATAL # define ELA __FILE__, __LINE__, EL_ALERT @@ -33,6 +42,15 @@ extern "C" { # define ELN __FILE__, __LINE__, EL_NOTICE # define ELI __FILE__, __LINE__, EL_INFO # define ELD __FILE__, __LINE__, EL_DBG + +# define OELF __FILE__, __LINE__, EL_FATAL, EL_OPTIONS_OBJECT +# define OELA __FILE__, __LINE__, EL_ALERT, EL_OPTIONS_OBJECT +# define OELC __FILE__, __LINE__, EL_CRIT, EL_OPTIONS_OBJECT +# define OELE __FILE__, __LINE__, EL_ERROR, EL_OPTIONS_OBJECT +# define OELW __FILE__, __LINE__, EL_WARN, EL_OPTIONS_OBJECT +# define OELN __FILE__, __LINE__, EL_NOTICE, EL_OPTIONS_OBJECT +# define OELI __FILE__, __LINE__, EL_INFO, EL_OPTIONS_OBJECT +# define OELD __FILE__, __LINE__, EL_DBG, EL_OPTIONS_OBJECT #endif #if (__STDC_VERSION__ >= 199901L) |