diff options
Diffstat (limited to 'libglusterfs/src')
| -rw-r--r-- | libglusterfs/src/common-utils.c | 35 | ||||
| -rw-r--r-- | libglusterfs/src/common-utils.h | 6 | ||||
| -rw-r--r-- | libglusterfs/src/glusterfs.h | 2 | ||||
| -rw-r--r-- | libglusterfs/src/logging.h | 12 | 
4 files changed, 55 insertions, 0 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 1ccb27d164c..bfc2fc6ade3 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -3048,3 +3048,38 @@ dht_is_linkfile (struct iatt *buf, dict_t *dict)          return linkfile_key_found;  } +int +gf_check_log_format (const char *value) +{ +        int log_format = -1; + +        if (!strcasecmp (value, GF_LOG_FORMAT_NO_MSG_ID)) +                log_format = gf_logformat_traditional; +        else if (!strcasecmp (value, GF_LOG_FORMAT_WITH_MSG_ID)) +                log_format = gf_logformat_withmsgid; + +        if (log_format == -1) +                gf_log (THIS->name, GF_LOG_ERROR, "Invalid log-format. " +                        "possible values are " +                        GF_LOG_FORMAT_NO_MSG_ID "|" GF_LOG_FORMAT_WITH_MSG_ID); + +        return log_format; +} + +int +gf_check_logger (const char *value) +{ +        int logger = -1; + +        if (!strcasecmp (value, GF_LOGGER_GLUSTER_LOG)) +                logger = gf_logger_glusterlog; +        else if (!strcasecmp (value, GF_LOGGER_SYSLOG)) +                logger = gf_logger_syslog; + +        if (logger == -1) +                gf_log (THIS->name, GF_LOG_ERROR, "Invalid logger. " +                        "possible values are " +                        GF_LOGGER_GLUSTER_LOG "|" GF_LOGGER_SYSLOG); + +        return logger; +} diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index ee4e5b7e6ee..26dcd314742 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -629,4 +629,10 @@ struct _dict;  inline gf_boolean_t  dht_is_linkfile (struct iatt *buf, struct _dict *dict); +int +gf_check_log_format (const char *value); + +int +gf_check_logger (const char *value); +  #endif /* _COMMON_UTILS_H */ diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 6a8e38a2182..c419308f9b5 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -346,6 +346,8 @@ struct _cmd_args {          gf_loglevel_t    log_level;          char            *log_file;          char            *log_ident; +        gf_log_logger_t  logger; +        gf_log_format_t  log_format;          int32_t          max_connect_attempts;          /* advanced options */          uint32_t         volfile_server_port; diff --git a/libglusterfs/src/logging.h b/libglusterfs/src/logging.h index b6b13fbd02a..210602c3210 100644 --- a/libglusterfs/src/logging.h +++ b/libglusterfs/src/logging.h @@ -48,6 +48,12 @@  #define LOG_DEBUG   7           /* debug-level messages */  #endif +#define GF_LOG_FORMAT_NO_MSG_ID       "no-msg-id" +#define GF_LOG_FORMAT_WITH_MSG_ID     "with-msg-id" + +#define GF_LOGGER_GLUSTER_LOG         "gluster-log" +#define GF_LOGGER_SYSLOG              "syslog" +  typedef enum {          GF_LOG_NONE,          GF_LOG_EMERG, @@ -254,6 +260,12 @@ void set_sys_log_level (gf_loglevel_t level);  int gf_log_fini(void *data); +void +gf_log_set_logger (gf_log_logger_t logger); + +void +gf_log_set_logformat (gf_log_format_t format); +  #define GF_DEBUG(xl, format, args...)                           \          gf_log ((xl)->name, GF_LOG_DEBUG, format, ##args)  #define GF_INFO(xl, format, args...)                            \  | 
