summaryrefslogtreecommitdiff
path: root/lib/zlog.h
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2021-03-03 00:14:02 +0100
committerDavid Lamparter <equinox@diac24.net>2021-03-22 12:50:27 +0100
commita3c67498603dbba7030d2cefe3395840a87e3f8d (patch)
treebcff4a0b821eaad7800129fdd16dc33ef1e45736 /lib/zlog.h
parent0e3967d766961020c800258755320b2175d0e97a (diff)
lib: add [XXXXX-XXXXX] log prefix & config
This logs the unique ID prefix from the xref that each log message call has, and adds on/off knobs for both EC and unique ID printing. Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib/zlog.h')
-rw-r--r--lib/zlog.h40
1 files changed, 13 insertions, 27 deletions
diff --git a/lib/zlog.h b/lib/zlog.h
index 25c2627f38..66d8f1e5d7 100644
--- a/lib/zlog.h
+++ b/lib/zlog.h
@@ -85,31 +85,6 @@ static inline void zlog_ref(const struct xref_logmsg *xref,
va_end(ap);
}
-#define _zlog_ref(prio, msg, ...) \
- do { \
- static struct xrefdata _xrefdata = { \
- .xref = NULL, \
- .uid = {}, \
- .hashstr = (msg), \
- .hashu32 = {(prio), 0}, \
- }; \
- static const struct xref_logmsg _xref __attribute__( \
- (used)) = { \
- .xref = XREF_INIT(XREFT_LOGMSG, &_xrefdata, __func__), \
- .fmtstring = (msg), \
- .priority = (prio), \
- .args = (#__VA_ARGS__), \
- }; \
- XREF_LINK(_xref.xref); \
- zlog_ref(&_xref, (msg), ##__VA_ARGS__); \
- } while (0)
-
-#define zlog_err(...) _zlog_ref(LOG_ERR, __VA_ARGS__)
-#define zlog_warn(...) _zlog_ref(LOG_WARNING, __VA_ARGS__)
-#define zlog_info(...) _zlog_ref(LOG_INFO, __VA_ARGS__)
-#define zlog_notice(...) _zlog_ref(LOG_NOTICE, __VA_ARGS__)
-#define zlog_debug(...) _zlog_ref(LOG_DEBUG, __VA_ARGS__)
-
#define _zlog_ecref(ec_, prio, msg, ...) \
do { \
static struct xrefdata _xrefdata = { \
@@ -127,16 +102,22 @@ static inline void zlog_ref(const struct xref_logmsg *xref,
.args = (#__VA_ARGS__), \
}; \
XREF_LINK(_xref.xref); \
- zlog_ref(&_xref, "[EC %u] " msg, ec_, ##__VA_ARGS__); \
+ zlog_ref(&_xref, (msg), ##__VA_ARGS__); \
} while (0)
+#define zlog_err(...) _zlog_ecref(0, LOG_ERR, __VA_ARGS__)
+#define zlog_warn(...) _zlog_ecref(0, LOG_WARNING, __VA_ARGS__)
+#define zlog_info(...) _zlog_ecref(0, LOG_INFO, __VA_ARGS__)
+#define zlog_notice(...) _zlog_ecref(0, LOG_NOTICE, __VA_ARGS__)
+#define zlog_debug(...) _zlog_ecref(0, LOG_DEBUG, __VA_ARGS__)
+
#define flog_err(ferr_id, format, ...) \
_zlog_ecref(ferr_id, LOG_ERR, format, ## __VA_ARGS__)
#define flog_warn(ferr_id, format, ...) \
_zlog_ecref(ferr_id, LOG_WARNING, format, ## __VA_ARGS__)
#define flog_err_sys(ferr_id, format, ...) \
- flog_err(ferr_id, format, ##__VA_ARGS__)
+ _zlog_ecref(ferr_id, LOG_ERR, format, ## __VA_ARGS__)
extern void zlog_sigsafe(const char *text, size_t len);
@@ -250,6 +231,11 @@ DECLARE_HOOK(zlog_init, (const char *progname, const char *protoname,
extern void zlog_fini(void);
DECLARE_KOOH(zlog_fini, (), ());
+extern void zlog_set_prefix_ec(bool enable);
+extern bool zlog_get_prefix_ec(void);
+extern void zlog_set_prefix_xid(bool enable);
+extern bool zlog_get_prefix_xid(void);
+
/* for tools & test programs, i.e. anything not a daemon.
* (no cleanup needed at exit)
*/