Re: [PATCH] Logging to syslog

2010-11-16 Thread Nikos Balkanas
Good idea, just that wapbox already supports syslog. It would be good to use 
the same archotecture for the rest.


BR,
Nikos
- Original Message - 
From: "Alejandro Guerrieri" 

To: "Devel Kannel" 
Sent: Tuesday, November 16, 2010 9:49 PM
Subject: [PATCH] Logging to syslog



Proposed patch implements syslog logging on bearerbox, smsbox and wapbox.

More details and a link the the patch here:

http://www.blogalex.com/archives/240

Please review. I'll write the userguide patch if it's accepted.

Regards,
--
Alejandro Guerrieri
aguerri...@kannel.org







Re: [PATCH] Logging to syslog

2010-11-16 Thread Alejandro Guerrieri
Check the patch, that's what I did... I've extended what there was on wapbox (I 
don't think it was working actually).

Regerds,
--
Alejandro Guerrieri
aguerri...@kannel.org



On 16/11/2010, at 21:07, Nikos Balkanas wrote:

> Good idea, just that wapbox already supports syslog. It would be good to use 
> the same archotecture for the rest.
> 
> BR,
> Nikos
> - Original Message - From: "Alejandro Guerrieri" 
> 
> To: "Devel Kannel" 
> Sent: Tuesday, November 16, 2010 9:49 PM
> Subject: [PATCH] Logging to syslog
> 
> 
>> Proposed patch implements syslog logging on bearerbox, smsbox and wapbox.
>> 
>> More details and a link the the patch here:
>> 
>> http://www.blogalex.com/archives/240
>> 
>> Please review. I'll write the userguide patch if it's accepted.
>> 
>> Regards,
>> --
>> Alejandro Guerrieri
>> aguerri...@kannel.org
>> 
> 




Re: [PATCH] Logging to syslog

2010-11-16 Thread Nikos Balkanas

Sorry, don't have the time.

BR,
Nikos
- Original Message - 
From: "Alejandro Guerrieri" 

To: "Nikos Balkanas" 
Cc: "Devel Kannel" 
Sent: Tuesday, November 16, 2010 10:11 PM
Subject: Re: [PATCH] Logging to syslog


Check the patch, that's what I did... I've extended what there was on wapbox 
(I don't think it was working actually).


Regerds,
--
Alejandro Guerrieri
aguerri...@kannel.org



On 16/11/2010, at 21:07, Nikos Balkanas wrote:

Good idea, just that wapbox already supports syslog. It would be good to 
use the same archotecture for the rest.


BR,
Nikos
- Original Message - From: "Alejandro Guerrieri" 


To: "Devel Kannel" 
Sent: Tuesday, November 16, 2010 9:49 PM
Subject: [PATCH] Logging to syslog



Proposed patch implements syslog logging on bearerbox, smsbox and wapbox.

More details and a link the the patch here:

http://www.blogalex.com/archives/240

Please review. I'll write the userguide patch if it's accepted.

Regards,
--
Alejandro Guerrieri
aguerri...@kannel.org








Re: [PATCH] Logging to syslog

2010-11-30 Thread Stipe Tolj
Am 16.11.2010 20:49, schrieb Alejandro Guerrieri:
> Proposed patch implements syslog logging on bearerbox, smsbox and wapbox.
> 
> More details and a link the the patch here:
> 
> http://www.blogalex.com/archives/240
> 
> Please review. I'll write the userguide patch if it's accepted.

I'd love to commit this.

Tested locally, but I don't see any DEBUG log entries passed to the syslog, at
least nothing in /var/log/messages?

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
---



Re: [PATCH] Logging to syslog

2010-11-30 Thread Alejandro Guerrieri
Have you tried playing with the log levels? Syslog accepts up to 7 logging 
levels.

I'll start writing the documentation in the meantime.

Regards,
--
Alejandro Guerrieri
aguerri...@kannel.org


On 30/11/2010, at 12:48, Stipe Tolj wrote:

> Am 16.11.2010 20:49, schrieb Alejandro Guerrieri:
>> Proposed patch implements syslog logging on bearerbox, smsbox and wapbox.
>> 
>> More details and a link the the patch here:
>> 
>> http://www.blogalex.com/archives/240
>> 
>> Please review. I'll write the userguide patch if it's accepted.
> 
> I'd love to commit this.
> 
> Tested locally, but I don't see any DEBUG log entries passed to the syslog, at
> least nothing in /var/log/messages?
> 
> 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
> ---
> 




Re: [PATCH] Logging to syslog

2010-11-30 Thread Stipe Tolj
Am 30.11.2010 12:58, schrieb Alejandro Guerrieri:
> Have you tried playing with the log levels? Syslog accepts up to 7 logging 
> levels.
> 
> I'll start writing the documentation in the meantime.

ok, my fault, I was looking into /var/log/messages only, where I should have
looked into /var/log/syslog actually. There the various log-levels work out.

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
---



Re: [PATCH] Logging to syslog

2010-11-30 Thread 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.

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
---



Re: [PATCH] Logging to syslog

2010-11-30 Thread Alexander Malysh
Hi,

please don't allow changing syslog-faility because it's "standartized" to use 
log_daemon for 
daemons which bearerbox/smsbox/wapbox is.

Thanks,
Alexander Malysh

Am 30.11.2010 um 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.
> 
> 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
> ---
> 




Re: [PATCH] Logging to syslog

2010-11-30 Thread Alejandro Guerrieri
That's extremely unflexible imho. If you want to get kannel to log alone 
without being cluttered with other daemon's logs, you're out of luck.

In our case, we'd like to use it for remote logging, so we'd use one of the 
"user" facilities to get kannel and _only_ kannel on it, directed to 
kannel-only log files.

I don't see the problem on allowing the extra flexibility. It's definitely 
useful for our scenario at least.

Regards,
--
Alejandro Guerrieri
aguerri...@kannel.org



On 30/11/2010, at 14:39, Alexander Malysh wrote:

> Hi,
> 
> please don't allow changing syslog-faility because it's "standartized" to use 
> log_daemon for 
> daemons which bearerbox/smsbox/wapbox is.
> 
> Thanks,
> Alexander Malysh
> 
> Am 30.11.2010 um 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.
>> 
>> 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
>> ---
>> 
> 




Re: [PATCH] Logging to syslog

2010-11-30 Thread Stipe Tolj
Am 30.11.2010 14:45, schrieb Alejandro Guerrieri:
> That's extremely unflexible imho. If you want to get kannel to log alone 
> without being cluttered with other daemon's logs, you're out of luck.
> 
> In our case, we'd like to use it for remote logging, so we'd use one of the 
> "user" facilities to get kannel and _only_ kannel on it, directed to 
> kannel-only log files.
> 
> I don't see the problem on allowing the extra flexibility. It's definitely 
> useful for our scenario at least.

yep, agree... we keep the default as Alexander suggest as 'LOG_DAEMON' facility,
but provide the capabilities to extend what we want. Right?

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
---



Re: [PATCH] Logging to syslog

2010-11-30 Thread Stipe Tolj
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
---



Re: [PATCH] Logging to syslog

2010-11-30 Thread Milan P. Stanic
On Tue, 2010-11-30 at 14:58, Stipe Tolj wrote:
> Am 30.11.2010 14:45, schrieb Alejandro Guerrieri:
> > That's extremely unflexible imho. If you want to get kannel to log alone 
> > without being cluttered with other daemon's logs, you're out of luck.
> > 
> > In our case, we'd like to use it for remote logging, so we'd use one of the 
> > "user" facilities to get kannel and _only_ kannel on it, directed to 
> > kannel-only log files.
> > 
> > I don't see the problem on allowing the extra flexibility. It's definitely 
> > useful for our scenario at least.
> 
> yep, agree... we keep the default as Alexander suggest as 'LOG_DAEMON' 
> facility,
> but provide the capabilities to extend what we want. Right?

Right, IMHO.

Most modern syslog servers have options to match program name (even
regex) and dispatch log messages according to admin defined rules.

-- 
Kind regards,  Milan
--
Arvanta, IT Securityhttp://www.arvanta.net
Please do not send me e-mail containing HTML code.



Re: [PATCH] Logging to syslog

2010-11-30 Thread Alejandro Guerrieri
I'm fine with that :)
--
Alejandro Guerrieri
aguerri...@kannel.org



On 30/11/2010, at 14:58, Stipe Tolj wrote:

> Am 30.11.2010 14:45, schrieb Alejandro Guerrieri:
>> That's extremely unflexible imho. If you want to get kannel to log alone 
>> without being cluttered with other daemon's logs, you're out of luck.
>> 
>> In our case, we'd like to use it for remote logging, so we'd use one of the 
>> "user" facilities to get kannel and _only_ kannel on it, directed to 
>> kannel-only log files.
>> 
>> I don't see the problem on allowing the extra flexibility. It's definitely 
>> useful for our scenario at least.
> 
> yep, agree... we keep the default as Alexander suggest as 'LOG_DAEMON' 
> facility,
> but provide the capabilities to extend what we want. Right?
> 
> 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
> ---
> 




Re: [PATCH] Logging to syslog

2010-11-30 Thread Alexander Malysh
I mean, we should not allow to change syslog-facility because it's standard to 
use daemon.
and most modern syslog daemons allow you match program name and some of then 
even regex match.

Thanks,
Alexander Malysh

Am 30.11.2010 um 14:58 schrieb Stipe Tolj:

> Am 30.11.2010 14:45, schrieb Alejandro Guerrieri:
>> That's extremely unflexible imho. If you want to get kannel to log alone 
>> without being cluttered with other daemon's logs, you're out of luck.
>> 
>> In our case, we'd like to use it for remote logging, so we'd use one of the 
>> "user" facilities to get kannel and _only_ kannel on it, directed to 
>> kannel-only log files.
>> 
>> I don't see the problem on allowing the extra flexibility. It's definitely 
>> useful for our scenario at least.
> 
> yep, agree... we keep the default as Alexander suggest as 'LOG_DAEMON' 
> facility,
> but provide the capabilities to extend what we want. Right?
> 
> 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
> ---
> 




Re: [PATCH] Logging to syslog

2010-11-30 Thread Alejandro Guerrieri
Does it hurt to be able to change it? Really?

I'm all for correctness, but extra flexibility is usually welcomed imho.
--
Alejandro Guerrieri
aguerri...@kannel.org



On 30/11/2010, at 15:26, Alexander Malysh wrote:

> I mean, we should not allow to change syslog-facility because it's standard 
> to use daemon.
> and most modern syslog daemons allow you match program name and some of then 
> even regex match.
> 
> Thanks,
> Alexander Malysh
> 
> Am 30.11.2010 um 14:58 schrieb Stipe Tolj:
> 
>> Am 30.11.2010 14:45, schrieb Alejandro Guerrieri:
>>> That's extremely unflexible imho. If you want to get kannel to log alone 
>>> without being cluttered with other daemon's logs, you're out of luck.
>>> 
>>> In our case, we'd like to use it for remote logging, so we'd use one of the 
>>> "user" facilities to get kannel and _only_ kannel on it, directed to 
>>> kannel-only log files.
>>> 
>>> I don't see the problem on allowing the extra flexibility. It's definitely 
>>> useful for our scenario at least.
>> 
>> yep, agree... we keep the default as Alexander suggest as 'LOG_DAEMON' 
>> facility,
>> but provide the capabilities to extend what we want. Right?
>> 
>> 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
>> ---
>> 
> 
> 




Re: [PATCH] Logging to syslog

2010-11-30 Thread Alexander Malysh
it doesn't hurt really but the same argument apply to any specification. Do we 
need to be correct in implementing specs?
we have to use standard and don't try to violate it.

I'm -0 for facility config but not blocking. We have to vote for this change.

Thanks,
Alexander Malysh

Am 30.11.2010 um 15:52 schrieb Alejandro Guerrieri:

> Does it hurt to be able to change it? Really?
> 
> I'm all for correctness, but extra flexibility is usually welcomed imho.
> --
> Alejandro Guerrieri
> aguerri...@kannel.org
> 
> 
> 
> On 30/11/2010, at 15:26, Alexander Malysh wrote:
> 
>> I mean, we should not allow to change syslog-facility because it's standard 
>> to use daemon.
>> and most modern syslog daemons allow you match program name and some of then 
>> even regex match.
>> 
>> Thanks,
>> Alexander Malysh
>> 
>> Am 30.11.2010 um 14:58 schrieb Stipe Tolj:
>> 
>>> Am 30.11.2010 14:45, schrieb Alejandro Guerrieri:
 That's extremely unflexible imho. If you want to get kannel to log alone 
 without being cluttered with other daemon's logs, you're out of luck.
 
 In our case, we'd like to use it for remote logging, so we'd use one of 
 the "user" facilities to get kannel and _only_ kannel on it, directed to 
 kannel-only log files.
 
 I don't see the problem on allowing the extra flexibility. It's definitely 
 useful for our scenario at least.
>>> 
>>> yep, agree... we keep the default as Alexander suggest as 'LOG_DAEMON' 
>>> facility,
>>> but provide the capabilities to extend what we want. Right?
>>> 
>>> 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
>>> ---
>>> 
>> 
>> 
> 




Re: [PATCH] Logging to syslog

2010-12-02 Thread Alexander Malysh
Hi,

I checked other daemons and it seems they allow changing of facility as well. 
Therefore I change
my opinion on this.

+1 for this patch.

Thanks,
Alexander Malysh

Am 30.11.2010 um 15:52 schrieb Alejandro Guerrieri:

> Does it hurt to be able to change it? Really?
> 
> I'm all for correctness, but extra flexibility is usually welcomed imho.
> --
> Alejandro Guerrieri
> aguerri...@kannel.org
> 
> 
> 
> On 30/11/2010, at 15:26, Alexander Malysh wrote:
> 
>> I mean, we should not allow to change syslog-facility because it's standard 
>> to use daemon.
>> and most modern syslog daemons allow you match program name and some of then 
>> even regex match.
>> 
>> Thanks,
>> Alexander Malysh
>> 
>> Am 30.11.2010 um 14:58 schrieb Stipe Tolj:
>> 
>>> Am 30.11.2010 14:45, schrieb Alejandro Guerrieri:
 That's extremely unflexible imho. If you want to get kannel to log alone 
 without being cluttered with other daemon's logs, you're out of luck.
 
 In our case, we'd like to use it for remote logging, so we'd use one of 
 the "user" facilities to get kannel and _only_ kannel on it, directed to 
 kannel-only log files.
 
 I don't see the problem on allowing the extra flexibility. It's definitely 
 useful for our scenario at least.
>>> 
>>> yep, agree... we keep the default as Alexander suggest as 'LOG_DAEMON' 
>>> facility,
>>> but provide the capabilities to extend what we want. Right?
>>> 
>>> 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
>>> ---
>>> 
>> 
>> 
> 




Re: [PATCH] Logging to syslog

2010-12-02 Thread Alejandro Guerrieri
Ok. I'll write the userguide documentation and commit afterwards.

Regards,
--
Alejandro Guerrieri
aguerri...@kannel.org



On 02/12/2010, at 18:15, Alexander Malysh wrote:

> Hi,
> 
> I checked other daemons and it seems they allow changing of facility as well. 
> Therefore I change
> my opinion on this.
> 
> +1 for this patch.
> 
> Thanks,
> Alexander Malysh
> 
> Am 30.11.2010 um 15:52 schrieb Alejandro Guerrieri:
> 
>> Does it hurt to be able to change it? Really?
>> 
>> I'm all for correctness, but extra flexibility is usually welcomed imho.
>> --
>> Alejandro Guerrieri
>> aguerri...@kannel.org
>> 
>> 
>> 
>> On 30/11/2010, at 15:26, Alexander Malysh wrote:
>> 
>>> I mean, we should not allow to change syslog-facility because it's standard 
>>> to use daemon.
>>> and most modern syslog daemons allow you match program name and some of 
>>> then even regex match.
>>> 
>>> Thanks,
>>> Alexander Malysh
>>> 
>>> Am 30.11.2010 um 14:58 schrieb Stipe Tolj:
>>> 
 Am 30.11.2010 14:45, schrieb Alejandro Guerrieri:
> That's extremely unflexible imho. If you want to get kannel to log alone 
> without being cluttered with other daemon's logs, you're out of luck.
> 
> In our case, we'd like to use it for remote logging, so we'd use one of 
> the "user" facilities to get kannel and _only_ kannel on it, directed to 
> kannel-only log files.
> 
> I don't see the problem on allowing the extra flexibility. It's 
> definitely useful for our scenario at least.
 
 yep, agree... we keep the default as Alexander suggest as 'LOG_DAEMON' 
 facility,
 but provide the capabilities to extend what we want. Right?
 
 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
 ---
 
>>> 
>>> 
>> 
> 




Re: [PATCH] Logging to syslog

2010-12-03 Thread Stipe Tolj
Am 02.12.2010 18:40, schrieb Alejandro Guerrieri:
> Ok. I'll write the userguide documentation and commit afterwards.

thanks Alejandro.

I have made some source code intend cleanup, and removed some unnecessary
Octstr* that have been used. So it's a bit more "compact" now. In addition added
the "without []" logging for the syslog target, so we don't duplicates of
PID values in the syslog line.

Can you please use the attached patch as "base" for the commit? ;)

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
---
Index: gwlib/cfg.def
===
--- gwlib/cfg.def   (revision 4871)
+++ gwlib/cfg.def   (working copy)
@@ -94,6 +94,8 @@
 OCTSTR(wdp-interface-name)
 OCTSTR(log-file)
 OCTSTR(log-level)
+OCTSTR(syslog-level)
+OCTSTR(syslog-facility)
 OCTSTR(access-log)
 OCTSTR(access-log-time)
 OCTSTR(access-log-format)
@@ -152,6 +154,7 @@
 OCTSTR(log-file)
 OCTSTR(log-level)
 OCTSTR(syslog-level)
+OCTSTR(syslog-facility)
 OCTSTR(smart-errors)
 OCTSTR(access-log)
 OCTSTR(access-log-time)
@@ -263,6 +266,8 @@
 OCTSTR(global-sender)
 OCTSTR(log-file)
 OCTSTR(log-level)
+OCTSTR(syslog-level)
+OCTSTR(syslog-facility)
 OCTSTR(access-log)
 OCTSTR(access-log-time)
 OCTSTR(access-log-clean)
Index: gwlib/log.c
===
--- gwlib/log.c (revision 4871)
+++ gwlib/log.c (working copy)
@@ -66,12 +66,14 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef HAVE_EXECINFO_H
 #include 
 #endif
 
 #if HAVE_SYSLOG_H
+#defineSYSLOG_NAMES
 #include 
 #else
 
@@ -144,9 +146,27 @@
  * Syslog support.
  */
 static int sysloglevel;
+static int syslogfacility = LOG_DAEMON;
 static int dosyslog = 0;
 
+/*
+ * Decode the syslog name to its int value
+ */
+static int decode(char *name, CODE *facilities)
+{
+   register CODE *c;
 
+   if (isdigit(*name)) {
+   return (atoi(name));
+   }
+   for (c = facilities; c->c_name; c++) {
+   if (!strcasecmp(name, c->c_name)) {
+   return (c->c_val);
+   }
+   }
+   return LOG_DAEMON;
+}
+
 /*
  * Make sure stderr is included in the list.
  */
@@ -192,10 +212,10 @@
 int i;
 
 for (i = 0; i < num_logfiles; ++i) {
-   if (logfiles[i].file == stderr) {
-   logfiles[i].minimum_output_level = level;
-   break;
-   }
+if (logfiles[i].file == stderr) {
+logfiles[i].minimum_output_level = level;
+break;
+}
 }
 }
 
@@ -212,16 +232,21 @@
 }
 }
 
+void log_set_syslog_facility(char *facility)
+{
+if (facility != NULL)
+syslogfacility = decode(facility, facilitynames);
+}
 
 void log_set_syslog(const char *ident, int syslog_level)
 {
 if (ident == NULL)
-   dosyslog = 0;
+dosyslog = 0;
 else {
-   dosyslog = 1;
-   sysloglevel = syslog_level;
-   openlog(ident, LOG_PID, LOG_DAEMON);
-   debug("gwlib.log", 0, "Syslog logging enabled.");
+dosyslog = 1;
+sysloglevel = syslog_level;
+openlog(ident, LOG_PID, syslogfacility);
+debug("gwlib.log", 0, "Syslog logging enabled.");
 }
 }
 
@@ -360,15 +385,15 @@
 
 #define FORMAT_SIZE (1024)
 static void format(char *buf, int level, const char *place, int e,
-  const char *fmt, int with_timestamp)
+  const char *fmt, int with_timestamp_and_pid)
 {
 static char *tab[] = {
-   "DEBUG: ",
-   "INFO: ",
-   "WARNING: ",
-   "ERROR: ",
-   "PANIC: ",
-   "LOG: "
+"DEBUG: ",
+"INFO: ",
+"WARNING: ",
+"ERROR: ",
+"PANIC: ",
+"LOG: "
 };
 static int tab_size = sizeof(tab) / sizeof(tab[0]);
 time_t t;
@@ -378,7 +403,7 @@
 
 p = prefix;
 
-if (with_timestamp) {
+if (with_timestamp_and_pid) {
 time(&t);
 #if LOG_TIMESTAMP_LOCALTIME
 tm = gw_localtime(t);
@@ -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);
-
 p = strchr(p, '\0');
 if (level < 0 || level >= tab_size)
-   spri

Re: [PATCH] Logging to syslog

2011-01-10 Thread Alejandro Guerrieri
Commited to SVN with the corresponding userguide mods.

Regards,
--
Alejandro Guerrieri
aguerri...@kannel.org

On 03/12/2010, at 15:05, Stipe Tolj wrote:

> Am 02.12.2010 18:40, schrieb Alejandro Guerrieri:
>> Ok. I'll write the userguide documentation and commit afterwards.
> 
> thanks Alejandro.
> 
> I have made some source code intend cleanup, and removed some unnecessary
> Octstr* that have been used. So it's a bit more "compact" now. In addition 
> added
> the "without []" logging for the syslog target, so we don't duplicates of
> PID values in the syslog line.
> 
> Can you please use the attached patch as "base" for the commit? ;)
> 
> 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
> ---
> 




Re: [PATCH] Logging to syslog

2011-01-10 Thread Stipe Tolj
Am 10.01.2011 15:43, schrieb Alejandro Guerrieri:
> Commited to SVN with the corresponding userguide mods.

thanks Alejandro!

I just did some ChangeLog entry "beautifying", hope you don't mind my pedantics 
:p

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
---



smime.p7s
Description: S/MIME Cryptographic Signature


Re: [PATCH] Logging to syslog

2011-01-10 Thread Alejandro Guerrieri
Not at all! :)
--
Alejandro Guerrieri
aguerri...@kannel.org



On 10/01/2011, at 16:20, Stipe Tolj wrote:

> Am 10.01.2011 15:43, schrieb Alejandro Guerrieri:
>> Commited to SVN with the corresponding userguide mods.
> 
> thanks Alejandro!
> 
> I just did some ChangeLog entry "beautifying", hope you don't mind my 
> pedantics :p
> 
> 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
> ---
>