Re: [PATCH] Logging to syslog
Stipe Tolj <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Organization | tolj.org system architecture |
| Message-ID | <[email protected]> |
Am 30.11.2010 13:41, schrieb Stipe Tolj:
> looking at the created output to /var/log/syslog:
>
> Nov 30 13:40:28 xxx bearerbox[24686]: [24686] [6] ERROR: error connecting to
> server `localhost' at port `2345'
> Nov 30 13:40:28 xxx bearerbox[24686]: [24686] [6] ERROR: SMPP[smpp_a]: Couldn't
> connect to server.
>
> it would be nice to ommit the OWN [pid] value here, since syslog provides us
> with that information already. Sort of double the information and takes away the
> space for the "real" log message.
>
> Checking if we can do this without performance loose.
yep, possible, with minimal change in gwlib/log.c:format() itself:
This is the changed chunk:
@@ -388,33 +413,38 @@
sprintf(p, "%04d-%02d-%02d %02d:%02d:%02d ",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec);
-
+
p = strchr(p, '\0');
+
+ /* print PID and thread ID */
+ gwthread_self_ids(&tid, &pid);
+ sprintf(p, "[%ld] [%ld] ", pid, tid);
+ } else {
+ /* thread ID only */
+ tid = gwthread_self();
+ sprintf(p, "[%ld] ", tid);
}
- gwthread_self_ids(&tid, &pid);
- sprintf(p, "[%ld] [%ld] ", pid, tid);
-
Which means, IF we triggered timestamp to be included, when we include PID too,
if NOT then there won't be a PID neither.
This way we use the existing if branch and there is no extra time spend of the
check.
Stipe
--
-------------------------------------------------------------------
Kölner Landstrasse 419
40589 Düsseldorf, NRW, Germany
tolj.org system architecture Kannel Software Foundation (KSF)
http://www.tolj.org/ http://www.kannel.org/
mailto:st_{at}_tolj.org mailto:stolj_{at}_kannel.org
-------------------------------------------------------------------