Browse Source

provide convenience function get_log_level()

pull/101/head
Richard Fuchs 11 years ago
parent
commit
a81588e313
3 changed files with 12 additions and 9 deletions
  1. +1
    -1
      daemon/log.c
  2. +3
    -0
      daemon/log.h
  3. +8
    -8
      daemon/main.c

+ 1
- 1
daemon/log.c View File

@ -96,7 +96,7 @@ void ilog(int prio, const char *fmt, ...) {
#ifndef __DEBUG
int level; /* thank you C99 */
level = g_atomic_int_get(&log_level);
level = get_log_level();
if (xprio > LOG_LEVEL_MASK(level))
return;
if ((level & LOG_FLAG_RESTORE) && !(prio & LOG_FLAG_RESTORE))


+ 3
- 0
daemon/log.h View File

@ -79,6 +79,9 @@ INLINE void log_info_stream_fd(struct stream_fd *sfd) {
log_info.e = LOG_INFO_STREAM_FD;
log_info.u.stream_fd = __obj_get((void *) sfd);
}
INLINE int get_log_level(void) {
return g_atomic_int_get(&log_level);
}


+ 8
- 8
daemon/main.c View File

@ -135,19 +135,19 @@ static void sighandler(gpointer x) {
if (ret == SIGINT || ret == SIGTERM)
global_shutdown = 1;
else if (ret == SIGUSR1) {
if (g_atomic_int_get(&log_level) > 0) {
if (get_log_level() > 0) {
g_atomic_int_add(&log_level, -1);
setlogmask(LOG_UPTO(g_atomic_int_get(&log_level)));
ilog(g_atomic_int_get(&log_level), "Set log level to %d\n",
g_atomic_int_get(&log_level));
setlogmask(LOG_UPTO(get_log_level()));
ilog(get_log_level(), "Set log level to %d\n",
get_log_level());
}
}
else if (ret == SIGUSR2) {
if (g_atomic_int_get(&log_level) < 7) {
if (get_log_level() < 7) {
g_atomic_int_add(&log_level, 1);
setlogmask(LOG_UPTO(g_atomic_int_get(&log_level)));
ilog(g_atomic_int_get(&log_level), "Set log level to %d\n",
g_atomic_int_get(&log_level));
setlogmask(LOG_UPTO(get_log_level()));
ilog(get_log_level(), "Set log level to %d\n",
get_log_level());
}
}
else


Loading…
Cancel
Save