diff options
author | Aravinda VK <avishwan@redhat.com> | 2017-06-14 13:31:42 +0530 |
---|---|---|
committer | Jeff Darcy <jeff@pl.atyp.us> | 2017-06-29 11:55:39 +0000 |
commit | c0f1db29a2d8b3eb1311ad60c2935da0aff7ab70 (patch) | |
tree | 61acaa5f48ed93c011da4e92b4d37114f1a1a71b /libglusterfs/src/logging.h | |
parent | e9c5b61861299add8bf4b61382611cda68ebb68c (diff) |
logging: Support for Structured logging format
Wrapper for `gf_log` and `gf_msg` to add support for
structured logging format.
Two new wrappers available `gf_slog` and `gf_smsg`
Example 1: All static details
gf_slog ("cli", GF_LOG_INFO, "Volume Set",
"name=gv1",
"option=changelog.changelog",
"value=on",
NULL);
gf_smsg ("cli", GF_LOG_INFO, 0, MSGID_VOLUME_SET,
"Volume Set",
"name=gv1",
"option=changelog.changelog",
"value=on",
NULL);
Example 2: Using Format chars in key values
gf_slog ("cli", GF_LOG_INFO, "Volume Set",
"name=%s", volume_name,
"option=%s", option_name,
"value=%s", option_value,
NULL);
gf_smsg ("cli", GF_LOG_INFO, 0, MSGID_VOLUME_SET,
"Volume Set",
"name=%s", volume_name,
"option=%s", option_name,
"value=%s", option_value,
NULL);
Formats as,
<EVENT><TAB><KEY1=VALUE1><TAB><KEY2=VALUE2>...
Example:
Volume Set name=gv1 option=changelog.changelog value=on
Updates: #240
Change-Id: I871727be16a39f681d41f363daa0029b8066fb52
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: https://review.gluster.org/17543
Reviewed-by: MOHIT AGRAWAL <moagrawa@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Tested-by: Amar Tumballi <amarts@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Diffstat (limited to 'libglusterfs/src/logging.h')
-rw-r--r-- | libglusterfs/src/logging.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libglusterfs/src/logging.h b/libglusterfs/src/logging.h index 78d57888f35..a7f252acf67 100644 --- a/libglusterfs/src/logging.h +++ b/libglusterfs/src/logging.h @@ -325,4 +325,24 @@ gf_log_disable_suppression_before_exit (struct _glusterfs_ctx *ctx); #define GF_ERROR(xl, format, args...) \ gf_log ((xl)->name, GF_LOG_ERROR, format, ##args) +int +_gf_slog (const char *domain, const char *file, const char *function, int line, + gf_loglevel_t level, const char *event, ...); + +int +_gf_smsg (const char *domain, const char *file, const char *function, + int32_t line, gf_loglevel_t level, int errnum, int trace, + uint64_t msgid, const char *event, ...); + +/* Interface to log messages with message IDs */ +#define gf_smsg(dom, levl, errnum, msgid, event...) do { \ + _gf_smsg (dom, __FILE__, __FUNCTION__, __LINE__, \ + levl, errnum, 0, msgid, ##event); \ + } while (0) + +#define gf_slog(dom, levl, event...) do { \ + _gf_slog (dom, __FILE__, __FUNCTION__, __LINE__, \ + levl, ##event); \ + } while (0) + #endif /* __LOGGING_H__ */ |