Browse Source

introduce log level flags (LOG_FLAG_RESTORE)

pull/6/head
Richard Fuchs 12 years ago
parent
commit
e19ca0a66e
3 changed files with 17 additions and 4 deletions
  1. +1
    -1
      daemon/call.c
  2. +11
    -3
      daemon/log.c
  3. +5
    -0
      daemon/log.h

+ 1
- 1
daemon/call.c View File

@ -2107,7 +2107,7 @@ static struct call *call_create(const str *callid, struct callmaster *m) {
struct call *c;
ilog(LOG_NOTICE, "["STR_FORMAT"] Creating new call",
STR_FMT(callid)); /* XXX will spam syslog on recovery from DB */
STR_FMT(callid));
c = obj_alloc0("call", sizeof(*c), __call_free);
c->callmaster = m;
mutex_init(&c->buffer_lock);


+ 11
- 3
daemon/log.c View File

@ -17,10 +17,18 @@ void ilog(int prio, const char *fmt, ...) {
char prefix[256];
char *msg;
va_list ap;
int ret;
int ret, xprio;
if (prio > g_atomic_int_get(&log_level))
xprio = LOG_LEVEL_MASK(prio);
#ifndef __DEBUG
int level; /* thank you C99 */
level = g_atomic_int_get(&log_level);
if (xprio > LOG_LEVEL_MASK(level))
return;
if ((level & LOG_FLAG_RESTORE) && !(prio & LOG_FLAG_RESTORE))
return;
#endif
switch (log_info.e) {
case LOG_INFO_NONE:
@ -47,7 +55,7 @@ void ilog(int prio, const char *fmt, ...) {
return;
}
syslog(prio, "%s%s", prefix, msg);
syslog(xprio, "%s%s", prefix, msg);
free(msg);
}


+ 5
- 0
daemon/log.h View File

@ -76,5 +76,10 @@ INLINE void log_info_stream_fd(struct stream_fd *sfd) {
#define LOG_WARN LOG_WARNING
#define LOG_LEVEL_MASK(v) ((v) & 0x0f)
#define LOG_FLAG_RESTORE 0x10
#endif

Loading…
Cancel
Save