Skip to content

Commit fcd2dbe

Browse files
committed
rewrite logging
1 parent aa5b771 commit fcd2dbe

File tree

12 files changed

+609
-635
lines changed

12 files changed

+609
-635
lines changed

include/common.h

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <stdlib.h>
88
#include <stdint.h>
99
#include <stdbool.h>
10+
#include <errno.h>
1011
#include <inttypes.h>
1112

1213
/* Defitition */
@@ -16,20 +17,29 @@
1617

1718
/* Macro */
1819

19-
#define pr_error(format, arg...) \
20-
fprintf(stderr, format, ##arg)
20+
#define prln_with_level(level, format, arg...) \
21+
fprintf(stderr, "[%s@"__FILE__":%u] " #level ": " format "\n", __func__, __LINE__, ##arg)
2122

22-
#define pr_error_with_errno(format, arg...) \
23-
pr_error(format", errno: %d, error: %s\n", ##arg, errno, strerror(errno))
23+
#define prln_fatal(format, arg...) \
24+
prln_with_level(fatal, format, ##arg)
2425

25-
#define pr_warn(format, arg...) \
26-
printf("%s:%d: "format, __FUNCTION__, __LINE__, ##arg)
26+
#define prln_error(format, arg...) \
27+
prln_with_level(error, format, ##arg)
28+
29+
#define prln_warn(format, arg...) \
30+
prln_with_level(warning, format, ##arg)
31+
32+
#define prln_info(format, arg...) \
33+
prln_with_level(info, format, ##arg)
2734

2835
#ifdef DEBUGGING
29-
#define pr_debug(format, arg...) \
30-
printf("%s:%d(debug): "format, __FUNCTION__, __LINE__, ##arg)
36+
#define prln_debug(format, arg...) \
37+
prln_with_level(debug, format, ##arg)
3138
#else
32-
#define pr_debug(format, arg...)
39+
#define prln_debug(format, arg...)
3340
#endif
3441

42+
#define prln_error_with_errno(format, arg...) \
43+
prln_error(format", errno: %d, error: %s", ##arg, errno, strerror(errno))
44+
3545
#endif

include/util.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ size_t
1515
char const * literal
1616
);
1717

18-
void
19-
util_log_title(
20-
const char * title
21-
);
22-
2318
long
2419
util_nearest_upper_bound_long(
2520
long value,

src/cli.c

Lines changed: 145 additions & 144 deletions
Large diffs are not rendered by default.

src/dtb.c

Lines changed: 80 additions & 80 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)