projects
/
yaz-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
90b039b
)
Attempt to enable log level on modules as well, without breaking existing behavior
author
Dennis Schafroth
<dennis@indexdata.com>
Tue, 22 May 2012 15:15:27 +0000
(17:15 +0200)
committer
Dennis Schafroth
<dennis@indexdata.com>
Tue, 22 May 2012 15:15:27 +0000
(17:15 +0200)
src/log.c
patch
|
blob
|
history
diff --git
a/src/log.c
b/src/log.c
index
673418b
..
7d03b8b
100644
(file)
--- a/
src/log.c
+++ b/
src/log.c
@@
-60,6
+60,8
@@
static char l_old_default_format[] = "%H:%M:%S-%d/%m";
static char l_new_default_format[] = "%Y%m%d-%H%M%S";
#define TIMEFORMAT_LEN 50
#define TID_LEN 30
static char l_new_default_format[] = "%Y%m%d-%H%M%S";
#define TIMEFORMAT_LEN 50
#define TID_LEN 30
+#define YLOG_LEVEL_MASK (YLOG_FATAL | YLOG_WARN | YLOG_LOG | YLOG_DEBUG )
+
static char l_custom_format[TIMEFORMAT_LEN] = "";
static char *l_actual_format = l_old_default_format;
static char l_custom_format[TIMEFORMAT_LEN] = "";
static char *l_actual_format = l_old_default_format;
@@
-98,6
+100,7
@@
static struct {
};
static unsigned int next_log_bit = YLOG_LAST_BIT<<1; /* first dynamic bit */
};
static unsigned int next_log_bit = YLOG_LAST_BIT<<1; /* first dynamic bit */
+static unsigned int module_logs = YLOG_LAST_BIT<<1; /* first dynamic bit */
static void internal_log_init(void)
{
static void internal_log_init(void)
{
@@
-438,6
+441,9
@@
static void yaz_log_to_file(int level, const char *log_message)
}
}
}
}
+static int is_module_log(int level) {
+ return level >= module_logs;
+}
void yaz_log(int level, const char *fmt, ...)
{
va_list ap;
void yaz_log(int level, const char *fmt, ...)
{
va_list ap;
@@
-448,6
+454,16
@@
void yaz_log(int level, const char *fmt, ...)
internal_log_init();
if (!(level & l_level))
return;
internal_log_init();
if (!(level & l_level))
return;
+ /* Modules without log level should log (as before) */
+ /* if there exists a log level as well this should be respected. */
+ if (is_module_log(level)) {
+ int module_log_level;
+ module_log_level = level & YLOG_LEVEL_MASK;
+ if (module_log_level != 0) {
+ if (!(module_log_level & l_level))
+ return;
+ }
+ }
va_start(ap, fmt);
/* 30 is enough for our 'rest of output' message */
va_start(ap, fmt);
/* 30 is enough for our 'rest of output' message */