diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2017-08-24 14:11:08 +0200 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2017-08-24 14:11:08 +0200 |
commit | 2457b02e5b17311b52c6a0b9971e00886466ba7b (patch) | |
tree | 376cb9ec0041dd13f7f4b9fc1ab3404035c5ffd9 | |
parent | 34ee856d5669db529355ff3e0b8afc3a81122914 (diff) | |
download | embedlog-2457b02e5b17311b52c6a0b9971e00886466ba7b.tar.gz embedlog-2457b02e5b17311b52c6a0b9971e00886466ba7b.tar.bz2 embedlog-2457b02e5b17311b52c6a0b9971e00886466ba7b.zip |
Moved level argument, so user can use 'ELD + n' syntax
-rw-r--r-- | include/embedlog.h | 32 | ||||
-rw-r--r-- | src/el-perror.c | 12 | ||||
-rw-r--r-- | src/el-pmemory.c | 22 | ||||
-rw-r--r-- | src/el-print.c | 14 |
4 files changed, 40 insertions, 40 deletions
diff --git a/include/embedlog.h b/include/embedlog.h index 44dd482..8f9b8df 100644 --- a/include/embedlog.h +++ b/include/embedlog.h @@ -12,15 +12,15 @@ #include <stdio.h> #if NOFINFO -# define ELE EL_LEVEL_ERR, NULL, 0 -# define ELW EL_LEVEL_WRN, NULL, 0 -# define ELI EL_LEVEL_INF, NULL, 0 -# define ELD EL_LEVEL_DBG, NULL, 0 +# define ELE NULL, 0, EL_LEVEL_ERR +# define ELW NULL, 0, EL_LEVEL_WRN +# define ELI NULL, 0, EL_LEVEL_INF +# define ELD NULL, 0, EL_LEVEL_DBG #else -# define ELE EL_LEVEL_ERR, __FILE__, __LINE__ -# define ELW EL_LEVEL_WRN, __FILE__, __LINE__ -# define ELI EL_LEVEL_INF, __FILE__, __LINE__ -# define ELD EL_LEVEL_DBG, __FILE__, __LINE__ +# define ELE __FILE__, __LINE__, EL_LEVEL_ERR +# define ELW __FILE__, __LINE__, EL_LEVEL_WRN +# define ELI __FILE__, __LINE__, EL_LEVEL_INF +# define ELD __FILE__, __LINE__, EL_LEVEL_DBG #endif #if (__STDC_VERSION__ >= 199901L) @@ -109,13 +109,13 @@ int el_output_enable(enum el_output output); int el_output_disable(enum el_output output); int el_option(enum el_option option, ...); int el_puts(const char *string); -int el_print(enum el_level level, const char *file, size_t line, +int el_print(const char *file, size_t line, enum el_level level, const char *fmt, ...); -int el_vprint(enum el_level level, const char *file, size_t line, +int el_vprint(const char *file, size_t line, enum el_level level, const char *fmt, va_list ap); -int el_pmemory(enum el_level level, const char *file, size_t line, +int el_pmemory(const char *file, size_t line, enum el_level level, const void *memory, size_t mlen); -int el_perror(enum el_level level, const char *file, size_t line, +int el_perror(const char *file, size_t line, enum el_level level, const char *fmt, ...); @@ -126,13 +126,13 @@ int el_ooutput_enable(struct el_options *options, enum el_output output); int el_ooutput_disable(struct el_options *options, enum el_output output); int el_ooption(struct el_options *options, enum el_option option, ...); int el_oputs(struct el_options *options, const char *string); -int el_oprint(enum el_level level, const char *file, size_t line, +int el_oprint(const char *file, size_t line, enum el_level level, struct el_options *options, const char *fnt, ...); -int el_ovprint(enum el_level level, const char *file, size_t line, +int el_ovprint(const char *file, size_t line, enum el_level level, struct el_options *options, const char *fmt, va_list ap); -int el_opmemory(enum el_level level, const char *file, size_t line, +int el_opmemory(const char *file, size_t line, enum el_level level, struct el_options *options, const void *memory, size_t mlen); -int el_operror(enum el_level level, const char *file, size_t line, +int el_operror(const char *file, size_t line, enum el_level level, struct el_options *options, const char *fmt, ...); diff --git a/src/el-perror.c b/src/el-perror.c index d5a3b69..c5a5d86 100644 --- a/src/el-perror.c +++ b/src/el-perror.c @@ -56,9 +56,9 @@ int el_perror ( - enum el_level level, /* log level to print message with */ const char *file, /* file name where log is printed */ size_t num, /* line number where log is printed */ + enum el_level level, /* log level to print message with */ const char *fmt, /* message format (see printf (3)) */ ... /* additional parameters for fmt */ ) @@ -72,8 +72,8 @@ int el_perror e = errno; va_start(ap, fmt); - rc = el_ovprint(level, file, num, &g_options, fmt, ap); - rc |= el_oprint(level, file, num, &g_options, + rc = el_ovprint(file, num, level, &g_options, fmt, ap); + rc |= el_oprint(file, num, level, &g_options, "errno num: %lu, strerror: %s", e, strerror(e)); va_end(ap); } @@ -86,9 +86,9 @@ int el_perror int el_operror ( - enum el_level level, /* log level to print message with */ const char *file, /* file name where log is printed */ size_t num, /* line number where log is printed*/ + enum el_level level, /* log level to print message with */ struct el_options *options, /* options defining printing style */ const char *fmt, /* message format (see printf (3)) */ ... /* additional parameters for fmt */ @@ -103,8 +103,8 @@ int el_operror e = errno; va_start(ap, fmt); - rc = el_ovprint(level, file, num, options, fmt, ap); - rc |= el_oprint(level, file, num, options, + rc = el_ovprint(file, num, level, options, fmt, ap); + rc |= el_oprint(file, num, level, options, "errno num: %lu, strerror: %s", e, strerror(e)); va_end(ap); } diff --git a/src/el-pmemory.c b/src/el-pmemory.c index 8bb319f..817aa19 100644 --- a/src/el-pmemory.c +++ b/src/el-pmemory.c @@ -72,9 +72,9 @@ static void el_print_line ( - enum el_level level, /* log level to print message with */ const char *file, /* file name where log is printed */ size_t num, /* line number where log is printed */ + enum el_level level, /* log level to print message with */ struct el_options *options, /* options defining printing style */ const unsigned char *buf, /* memory location to print */ size_t line_size, /* size of line in bytes */ @@ -126,7 +126,7 @@ static void el_print_line * print constructed line */ - el_oprint(level, file, num, options, "0x%04x %-*s %s", + el_oprint(file, num, level, options, "0x%04x %-*s %s", offset, EL_MEM_HEX_LEN, hex_data, char_data); } @@ -154,14 +154,14 @@ static void el_print_line int el_pmemory ( - enum el_level level, /* log level to print message with */ const char *file, /* file name where log is printed */ size_t num, /* line number where log is printed */ + enum el_level level, /* log level to print message with */ const void *mem, /* memory location to print */ size_t mlen /* number of bytes to print */ ) { - return el_opmemory(level, file, num, &g_options, mem, mlen); + return el_opmemory(file, num, level, &g_options, mem, mlen); } @@ -188,9 +188,9 @@ int el_pmemory int el_opmemory ( - enum el_level level, /* log level to print message with */ const char *file, /* file name where log is printed */ size_t num, /* line number where log is printed */ + enum el_level level, /* log level to print message with */ struct el_options *options, /* options defining printing style */ const void *mem, /* memory location to print */ size_t mlen /* number of bytes to print */ @@ -230,16 +230,16 @@ int el_opmemory * ------ ----------------------------------------------- ---------------- */ - el_oprint(level, file, num, options, "%.*s %.*s %.*s", + el_oprint(file, num, level, options, "%.*s %.*s %.*s", EL_MEM_OFFSET_LEN - 2, separator, EL_MEM_HEX_LEN - 1, separator, EL_MEM_CHAR_LEN, separator); - el_oprint(level, file, num, options, "%-*s%-*s%s", + el_oprint(file, num, level, options, "%-*s%-*s%s", EL_MEM_OFFSET_LEN, "offset", EL_MEM_HEX_LEN + 1, "hex", "ascii"); - el_oprint(level, file, num, options, "%.*s %.*s %.*s", + el_oprint(file, num, level, options, "%.*s %.*s %.*s", EL_MEM_OFFSET_LEN - 2, separator, EL_MEM_HEX_LEN - 1, separator, EL_MEM_CHAR_LEN, separator); @@ -252,7 +252,7 @@ int el_opmemory for (line_number = 0; line_number < lines_count; ++line_number) { - el_print_line(level, file, num, options, + el_print_line(file, num, level, options, mem, EL_MEM_LINE_SIZE, line_number); /* @@ -269,7 +269,7 @@ int el_opmemory if (last_line_size) { - el_print_line(level, file, num, options, + el_print_line(file, num, level, options, mem, last_line_size, line_number); } @@ -279,7 +279,7 @@ int el_opmemory * ------ ----------------------------------------------- ---------------- */ - el_oprint(level, file, num, options, "%.*s %.*s %.*s", + el_oprint(file, num, level, options, "%.*s %.*s %.*s", EL_MEM_OFFSET_LEN - 2, separator, EL_MEM_HEX_LEN - 1, separator, EL_MEM_CHAR_LEN, separator); diff --git a/src/el-print.c b/src/el-print.c index c4b85a6..cfa4712 100644 --- a/src/el-print.c +++ b/src/el-print.c @@ -431,9 +431,9 @@ static size_t el_finfo int el_print ( - enum el_level level, /* log level to print message with */ const char *file, /* file name where log is printed */ size_t num, /* line number where log is printed */ + enum el_level level, /* log level to print message with */ const char *fmt, /* message format (see printf (3)) */ ... /* additional parameters for fmt */ ) @@ -444,7 +444,7 @@ int el_print va_start(ap, fmt); - rc = el_ovprint(level, file, num, &g_options, fmt, ap); + rc = el_ovprint(file, num, level, &g_options, fmt, ap); va_end(ap); return rc; @@ -458,9 +458,9 @@ int el_print int el_oprint ( - enum el_level level, /* log level to print log with */ const char *file, /* file name to print in log */ size_t num, /* line number to print in log */ + enum el_level level, /* log level to print log with */ struct el_options *options, /* printing style options */ const char *fmt, /* message format (man printf) */ ... /* additional params for fmt */ @@ -472,7 +472,7 @@ int el_oprint va_start(ap, fmt); - rc = el_ovprint(level, file, num, options, fmt, ap); + rc = el_ovprint(file, num, level, options, fmt, ap); va_end(ap); return rc; @@ -486,14 +486,14 @@ int el_oprint int el_vprint ( - enum el_level level, /* log level to print message with */ const char *file, /* file name where log is printed */ size_t num, /* line number where log is printed */ + enum el_level level, /* log level to print message with */ const char *fmt, /* message format (see printf (3)) */ va_list ap /* additional parameters for fmt */ ) { - return el_ovprint(level, file, num, &g_options, fmt, ap); + return el_ovprint(file, num, level, &g_options, fmt, ap); } @@ -515,9 +515,9 @@ int el_vprint int el_ovprint ( - enum el_level level, /* log level to print log with */ const char *file, /* file name to print in log */ size_t num, /* line number to print in log */ + enum el_level level, /* log level to print log with */ struct el_options *options, /* options defining print style */ const char *fmt, /* message format (man printf) */ va_list ap /* additional params for fmt */ |