summaryrefslogtreecommitdiff
path: root/lib/zlog.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/zlog.h')
-rw-r--r--lib/zlog.h51
1 files changed, 19 insertions, 32 deletions
diff --git a/lib/zlog.h b/lib/zlog.h
index 3e86aa1345..66d8f1e5d7 100644
--- a/lib/zlog.h
+++ b/lib/zlog.h
@@ -44,6 +44,7 @@ struct xref_logmsg {
const char *fmtstring;
uint32_t priority;
uint32_t ec;
+ const char *args;
};
struct xrefdata_logmsg {
@@ -84,30 +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), \
- }; \
- 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 = { \
@@ -122,20 +99,25 @@ static inline void zlog_ref(const struct xref_logmsg *xref,
.fmtstring = (msg), \
.priority = (prio), \
.ec = (ec_), \
+ .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__)
-#define flog(priority, ferr_id, format, ...) \
- zlog(priority, "[EC %u] " format, ferr_id, ##__VA_ARGS__)
+ _zlog_ecref(ferr_id, LOG_ERR, format, ## __VA_ARGS__)
extern void zlog_sigsafe(const char *text, size_t len);
@@ -200,7 +182,7 @@ extern size_t zlog_msg_ts(struct zlog_msg *msg, char *out, size_t outsz,
* additional options. It MUST be the first field in that larger struct.
*/
-PREDECL_ATOMLIST(zlog_targets)
+PREDECL_ATOMLIST(zlog_targets);
struct zlog_target {
struct zlog_targets_item head;
@@ -244,17 +226,22 @@ extern void zlog_init(const char *progname, const char *protoname,
unsigned short instance, uid_t uid, gid_t gid);
DECLARE_HOOK(zlog_init, (const char *progname, const char *protoname,
unsigned short instance, uid_t uid, gid_t gid),
- (progname, protoname, instance, uid, gid))
+ (progname, protoname, instance, uid, gid));
extern void zlog_fini(void);
-DECLARE_KOOH(zlog_fini, (), ())
+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)
*/
extern void zlog_aux_init(const char *prefix, int prio_min);
DECLARE_HOOK(zlog_aux_init, (const char *prefix, int prio_min),
- (prefix, prio_min))
+ (prefix, prio_min));
extern void zlog_startup_end(void);