Re: [PATCH] fpm/feature: show function and line in error_log only on debug

From: Date: Sun, 13 Dec 2009 17:20:10 +0000
Subject: Re: [PATCH] fpm/feature: show function and line in error_log only on debug
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-46407@lists.php.net to get a copy of this message
Le 13 décembre 2009 17:39, Jérôme Loyet <jerome@loyet.net> a écrit : > Hi tony, > > in the FPM error_log, the function and the line, from which the log > function is called, are written to the error_log as show above: > > Dec 13 17:30:18.81042 [NOTICE] fpm_event_init_main(), line 87: > libevent: using epoll > > It's debug information and it's not relevant but for developers. The > attached patch change this behaviour showing function and line only > when the log_level is set to debug. > > Moreover, it adds the PID of the process which call the log function > but only in with a debug loglevel. > > Without debug: > Dec 13 17:32:59.383706 [NOTICE] libevent: using epoll > > With debug: > Dec 13 17:33:38.817841 [NOTICE] pid 7932, fpm_event_init_main(), line > 87: libevent: using epoll With the correct version of the patch (.txt extension). > > Hope it helps > ++ Jerome >

Index: sapi/fpm/fpm/zlog.c =================================================================== --- sapi/fpm/fpm/zlog.c (révision 292067) +++ sapi/fpm/fpm/zlog.c (copie de travail) @@ -73,7 +73,11 @@ saved_errno = errno; gettimeofday(&tv, 0); len = zlog_print_time(&tv, buf, buf_size); - len += snprintf(buf + len, buf_size - len, " [%s] %s(), line %d: ", level_names[flags & ZLOG_LEVEL_MASK], function, line); + if (zlog_level == ZLOG_DEBUG) { + len += snprintf(buf + len, buf_size - len, " [%s] pid %d, %s(), line %d: ", level_names[flags & ZLOG_LEVEL_MASK], getpid(), function, line); + } else { + len += snprintf(buf + len, buf_size - len, " [%s] ", level_names[flags & ZLOG_LEVEL_MASK]); + } if (len > buf_size - 1) { truncated = 1;
« previous php.internals (#46407) next »