Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
src/log.c | 25 +++++++++++++++++++++++--
src/log.h | 1 +
src/main.c | 2 +-
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/src/log.c b/src/log.c
index fc516bc..ae66a47 100644
--- a/src/log.c
+++ b/src/log.c
@@ -106,6 +106,27 @@ static void _log_save_ent(int level, int len)
memcpy(e->str, log_str, len);
}
+static const char *_log_level_name(int level)
+{
+ switch (level) {
+ case LOG_EMERG:
+ case LOG_ALERT:
+ case LOG_CRIT:
+ case LOG_ERR:
+ return "error";
+
+ case LOG_WARNING:
+ return "warning";
+
+ case LOG_NOTICE:
+ case LOG_INFO:
+ return "notice";
+ }
+
+ /* LOG_DEBUG and default */
+ return "debug";
+}
+
/*
* This log function:
* 1. formats the log message in the log_str buffer
@@ -145,8 +166,8 @@ void log_level(uint32_t space_id, uint32_t token_id, char *name_in,
int level, c
tid = syscall(SYS_gettid);
- ret = snprintf(log_str + pos, len - pos, "%llu [%u]: %s",
- (unsigned long long) monotime(), tid, name);
+ ret = snprintf(log_str + pos, len - pos, "%llu [%u] %s: %s",
+ (unsigned long long) monotime(), tid, _log_level_name(level), name);
pos += ret;
va_start(ap, fmt);
diff --git a/src/log.h b/src/log.h
index 2421597..9e43080 100644
--- a/src/log.h
+++ b/src/log.h
@@ -17,6 +17,7 @@ void close_logging(void);
void copy_log_dump(char *buf, int *len);
#define log_debug(fmt, args...) log_level(0, 0, NULL, LOG_DEBUG, fmt,
##args)
+#define log_notice(fmt, args...) log_level(0, 0, NULL, LOG_NOTICE, fmt,
##args)
#define log_space(space, fmt, args...) log_level(space->space_id, 0, NULL,
LOG_DEBUG, fmt, ##args)
#define log_token(token, fmt, args...) log_level(0, token->token_id, NULL,
LOG_DEBUG, fmt, ##args)
#define log_spoke(space, token, fmt, args...) log_level(space->space_id,
token->token_id, NULL, LOG_DEBUG, fmt, ##args)
diff --git a/src/main.c b/src/main.c
index 67b3d3c..34708ea 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1595,7 +1595,7 @@ static int do_daemon(void)
setup_groups();
- log_error("sanlock daemon started %s host %s time %llu",
+ log_notice("sanlock daemon started %s host %s time %llu",
RELEASE_VERSION, our_host_name_global,
(unsigned long long)time(NULL));
--
1.7.1