Re: [fw-general] Re: Serious logging - syslog and / or alternatives

2008-09-22 Thread Matthew Ratzloff
In that case, you might try what I said earlier.  Log some unique test
string, then tail the last X number of lines of syslog and check for a
matching string.  If that's all you can do, it's all you can do.
-Matt

On Mon, Sep 22, 2008 at 9:58 AM, Thomas Gelf <[EMAIL PROTECTED]> wrote:

> Hmmm... it's useless. I finally took the time to make some tests, it
> seems to be "impossible" to make PHP's syslog-calls fail. I changed
> permissions on /dev/log, I removed the device node - openlog() and
> syslog() always give back (boolean)true.
>
> Curious I also tried it from command line by calling /usr/bin/logger,
> the result was the same. Even if logger fails it gives me no error,
> see this strace snipplet as an example:
>
> > # strace logger test && echo "OK"
> > ...
> > connect(1, {sa_family=AF_FILE, path="/dev/log"}, 16) = -1 ENOENT
> >  (No such file or directory)
> > close(1)= 0
> > exit_group(0)   = ?
> > Process 4733 detached
> > OK
>
> So what would you suggest? Remove my tests for syslog() and openlog()
> return values from my Zend_Log_Writer_Syslog proposal? Or just leave
> them as they are? Can someone test behaviour on Windows 2003 R2? Are
> PHP's syslog functions aware of failing syslog calls on those systems?
>
> Kind regards,
> Thomas Gelf
>
> NB: I did all tests on Debian Etch and Debian Lenny, 64bit systems.
>
>
> Matthew Ratzloff schrieb:
>
>> Manually change the permissions for syslog on your local machine, make the
>> test fail, change the permissions to be correct and make sure the test
>> succeeds.  Maybe log something then strpos the contents of tail.  That's all
>> you can really do.
>>
>> -Matt
>>
> >
>
>> > I could achieve this by removing or changing permissions on /dev/log,
>> > no idea about Windows. But I've some doubt if doing so would make
>> > people running the tests happy :p
>> >
>> > Regards,
>> > Thomas
>>
>
>


[fw-general] Re: Serious logging - syslog and / or alternatives

2008-09-22 Thread Thomas Gelf

Hmmm... it's useless. I finally took the time to make some tests, it
seems to be "impossible" to make PHP's syslog-calls fail. I changed
permissions on /dev/log, I removed the device node - openlog() and
syslog() always give back (boolean)true.

Curious I also tried it from command line by calling /usr/bin/logger,
the result was the same. Even if logger fails it gives me no error,
see this strace snipplet as an example:

> # strace logger test && echo "OK"
> ...
> connect(1, {sa_family=AF_FILE, path="/dev/log"}, 16) = -1 ENOENT
>  (No such file or directory)
> close(1)= 0
> exit_group(0)   = ?
> Process 4733 detached
> OK

So what would you suggest? Remove my tests for syslog() and openlog()
return values from my Zend_Log_Writer_Syslog proposal? Or just leave
them as they are? Can someone test behaviour on Windows 2003 R2? Are
PHP's syslog functions aware of failing syslog calls on those systems?

Kind regards,
Thomas Gelf

NB: I did all tests on Debian Etch and Debian Lenny, 64bit systems.


Matthew Ratzloff schrieb:
Manually change the permissions for syslog on your local machine, make 
the test fail, change the permissions to be correct and make sure the 
test succeeds.  Maybe log something then strpos the contents of tail. 
 That's all you can really do.


-Matt

>

> I could achieve this by removing or changing permissions on /dev/log,
> no idea about Windows. But I've some doubt if doing so would make
> people running the tests happy :p
>
> Regards,
> Thomas




Re: [fw-general] Re: Serious logging - syslog and / or alternatives

2008-09-22 Thread Matthew Ratzloff
Manually change the permissions for syslog on your local machine, make the
test fail, change the permissions to be correct and make sure the test
succeeds.  Maybe log something then strpos the contents of tail.  That's all
you can really do.
-Matt

On Sat, Sep 20, 2008 at 2:48 AM, Thomas Gelf <[EMAIL PROTECTED]> wrote:

> Matthew Weier O'Phinney schrieb:
>
>> "Ready for Review" means that you're ready to receive community
>> feedback; it's up to you to make that decision. We ask that you have
>> community review for at least a week prior to then re-parenting it to
>> the 'Ready for Recommendation' area -- which is when the Zend internal
>> team will review it and decide whether to include it, and where.
>>
>
> Ok, so I'm ready for feedback right now ;-)
>
>  Edit the page. Below the area where you add content, there's a tree --
>> simply drag your page's entry to the appropriate section, and then save
>> the page.
>>
>
> Thank you, wouldn't have found that without your help!
>
> What about unit tests, do I have to provide them too? And specific for
> my proposal: any idea how the tests should look like? There are just
> three simple functions, shutdown() will and should never fail, the
> constructor and _write are failing when syslog itself has gone away.
>
> I could achieve this by removing or changing permissions on /dev/log,
> no idea about Windows. But I've some doubt if doing so would make
> people running the tests happy :p
>
> Regards,
> Thomas
>
>


[fw-general] Re: Serious logging - syslog and / or alternatives

2008-09-20 Thread Thomas Gelf

Matthew Weier O'Phinney schrieb:

"Ready for Review" means that you're ready to receive community
feedback; it's up to you to make that decision. We ask that you have
community review for at least a week prior to then re-parenting it to
the 'Ready for Recommendation' area -- which is when the Zend internal
team will review it and decide whether to include it, and where.


Ok, so I'm ready for feedback right now ;-)


Edit the page. Below the area where you add content, there's a tree --
simply drag your page's entry to the appropriate section, and then save
the page.


Thank you, wouldn't have found that without your help!

What about unit tests, do I have to provide them too? And specific for
my proposal: any idea how the tests should look like? There are just
three simple functions, shutdown() will and should never fail, the
constructor and _write are failing when syslog itself has gone away.

I could achieve this by removing or changing permissions on /dev/log,
no idea about Windows. But I've some doubt if doing so would make
people running the tests happy :p

Regards,
Thomas



Re: [fw-general] Re: Serious logging - syslog and / or alternatives

2008-09-19 Thread Matthew Weier O'Phinney
-- Thomas Gelf <[EMAIL PROTECTED]> wrote
(on Saturday, 20 September 2008, 12:55 AM +0200):
> Done:
> http://framework.zend.com/wiki/display/ZFPROP/Zend_Log_Writer_Syslog+-+Thomas+Gelf

Excellent, thanks!

> As it is my first proposal:
> -> do you consider it "ready for review"?

"Ready for Review" means that you're ready to receive community
feedback; it's up to you to make that decision. We ask that you have
community review for at least a week prior to then re-parenting it to
the 'Ready for Recommendation' area -- which is when the Zend internal
team will review it and decide whether to include it, and where.

> -> and if yes: how to move it there?

Edit the page. Below the area where you add content, there's a tree --
simply drag your page's entry to the appropriate section, and then save
the page.

> And: could you be so kind to delete the "Zend_Log_"-proposal for me? I
> created it accidentally and it seems that I'm not allowed to remove it.

I'll see what can be done about that. :)

> Thanks a lot for your help!
>
> Regards,
> Thomas
>
>
> Matthew Weier O'Phinney schrieb:
>> -- Thomas Gelf <[EMAIL PROTECTED]> wrote
>> (on Friday, 19 September 2008, 07:41 PM +0200):
>>> Here what Zend_Log_Writer_Syslog could look like:
>>
>> Could you write a proposal for this, please? This is definitely a useful
>> addition.
>

-- 
Matthew Weier O'Phinney
Software Architect   | [EMAIL PROTECTED]
Zend Framework   | http://framework.zend.com/


[fw-general] Re: Serious logging - syslog and / or alternatives

2008-09-19 Thread Thomas Gelf

Done:
http://framework.zend.com/wiki/display/ZFPROP/Zend_Log_Writer_Syslog+-+Thomas+Gelf

As it is my first proposal:
-> do you consider it "ready for review"?
-> and if yes: how to move it there?

And: could you be so kind to delete the "Zend_Log_"-proposal for me? I
created it accidentally and it seems that I'm not allowed to remove it.

Thanks a lot for your help!

Regards,
Thomas


Matthew Weier O'Phinney schrieb:

-- Thomas Gelf <[EMAIL PROTECTED]> wrote
(on Friday, 19 September 2008, 07:41 PM +0200):

Here what Zend_Log_Writer_Syslog could look like:


Could you write a proposal for this, please? This is definitely a useful
addition.




Re: [fw-general] Re: Serious logging - syslog and / or alternatives

2008-09-19 Thread Matthew Weier O'Phinney
-- Thomas Gelf <[EMAIL PROTECTED]> wrote
(on Friday, 19 September 2008, 07:41 PM +0200):
> Here what Zend_Log_Writer_Syslog could look like:

Could you write a proposal for this, please? This is definitely a useful
addition.

> class Zend_Log_Writer_Syslog extends Zend_Log_Writer_Abstract
> {
> /**
>  * Maps Zend_Log priorities to PHP's syslog priorities
>  * @var array
>  */
> protected $_priorities = array(Zend_Log::EMERG  => LOG_EMERG,
>Zend_Log::ALERT  => LOG_ALERT,
>Zend_Log::CRIT   => LOG_CRIT,
>Zend_Log::ERR=> LOG_ERR,
>Zend_Log::WARN   => LOG_WARNING,
>Zend_Log::NOTICE => LOG_NOTICE,
>Zend_Log::INFO   => LOG_INFO,
>Zend_Log::DEBUG  => LOG_DEBUG);
>
> /**
>  * The default log priority - for unmapped custom priorities
>  * @var string
>  */
> protected $_defaultPriority = LOG_NOTICE;
>
> public function __construct($application = 'Zend_Log')
> {
> if (false === @openlog($application, LOG_PID, LOG_USER)) {
> throw new Zend_Log_Exception('Cannot connect to syslog');
> }
> }
>
> /**
>  * Close syslog.
>  *
>  * @return void
>  */
> public function shutdown()
> {
> @closelog();
> }
>
> /**
>  * Write a message to syslog.
>  *
>  * @param  array  $event  event data
>  * @return void
>  */
> protected function _write($event)
> {
> if (array_key_exists($event['priority'], $this-> _priorities)) {
> $priority = $this-> _priorityStyles[$event['priority']];
> } else {
> $priority = $this-> _defaultPriority;
> }
>
> if (false === @syslog($priority, $event['message'])) {
> throw new Zend_Log_Exception('Unable to write to syslog');
> }
> }
> }
>
> Even if LOG_USER should be fine for most users (it is available on
> Windows too) methods allowing to change facility could be added, the
> rest should be fine.
>
> Could someone test if this would "work out of the box" on windows?
>
> Cheers,
> Thomas
>
> NB: I'm not sure about the @'s in front of the syslog functions - as
> syslog is working fine on all of my systems I never experienced
> such an error ;-) If no one knows I'll test it - if there is even
> one single scenario producing a PHP-notice they have to stay there.
>
>
> Thomas Gelf schrieb:
> > Hi list,
> >
> > as surely most of you have a lot of free time available I'll throw
> > in a new old topic to hopefully be discussed in this round ;-)
> >
> > It's about logging. I like Zend_Log, it's well done - but the writers
> > currently available are not an option for most of my projects. Let's
> > make some example:
> >
> > * stream writers writing to local files are running fine, are not
> >   blocking parallel requests and should be ok so far if you just
> >   want your logs to be written down somewhere
> >
> > * it's difficult to set up a secure environment allowing PHP scripts
> >   running under different UIDs writing to the same log file (mostly
> >   leading to insecure logfile permissions or strange hacks)
> >
> > * hacked PHP sites are able to modify (application) log entries if
> >   PHP is able to write to them
> >
> > * if you want a cronjob to rotate log files for a PHP-written daemon
> >   you have to implement signal handlers (who has ever done so knows
> >   that this could be a really funny task)
> >
> > * writing to DB is great for small projects - but impossible for sites
> >   with heavy traffic. If you want to handle high loads your application
> >   should be able to serve most requests without the need to connect to
> >   your database cluster
> >
> > * ZF documentation should make people aware of locking and therefore
> >   performance issues when using MyISAM instead of InnoDB on MySQL
> >
> > * who wants to achieve a distributed centralized logging is currently
> >   either forced to write it's own syslog writer or probably going to
> >   reimplement things syslog would usually do for you
> >
> > Said all this: why is there still no Zend_Log_Writer_Syslog? Windows
> > is no excuse - PHP's syslog() function exists also there, so we should
> > be able to satisfy ZF's rules. And those rare windows people taking
> > care of their logs will surely be able to find out where they are going
> > to finish ;-) We should however avoid LOCAL*-facilities, as far as I
> > know (didn't test it) they are not available on windows.
> >
> > Thanks for your feedback - and have a nice weekend!

-- 
Matthew Weier O'Phinney
Software Architect   | [EMAIL PROTECTED]
Zend Framework   | http://framework.zend.com/


[fw-general] Re: Serious logging - syslog and / or alternatives

2008-09-19 Thread Thomas Gelf

Here what Zend_Log_Writer_Syslog could look like:

class Zend_Log_Writer_Syslog extends Zend_Log_Writer_Abstract
{
/**
 * Maps Zend_Log priorities to PHP's syslog priorities
 * @var array
 */
protected $_priorities = array(Zend_Log::EMERG  => LOG_EMERG,
   Zend_Log::ALERT  => LOG_ALERT,
   Zend_Log::CRIT   => LOG_CRIT,
   Zend_Log::ERR=> LOG_ERR,
   Zend_Log::WARN   => LOG_WARNING,
   Zend_Log::NOTICE => LOG_NOTICE,
   Zend_Log::INFO   => LOG_INFO,
   Zend_Log::DEBUG  => LOG_DEBUG);

/**
 * The default log priority - for unmapped custom priorities
 * @var string
 */
protected $_defaultPriority = LOG_NOTICE;

public function __construct($application = 'Zend_Log')
{
if (false === @openlog($application, LOG_PID, LOG_USER)) {
throw new Zend_Log_Exception('Cannot connect to syslog');
}
}

/**
 * Close syslog.
 *
 * @return void
 */
public function shutdown()
{
@closelog();
}

/**
 * Write a message to syslog.
 *
 * @param  array  $event  event data
 * @return void
 */
protected function _write($event)
{
if (array_key_exists($event['priority'], $this->_priorities)) {
$priority = $this->_priorityStyles[$event['priority']];
} else {
$priority = $this->_defaultPriority;
}

if (false === @syslog($priority, $event['message'])) {
throw new Zend_Log_Exception('Unable to write to syslog');
}
}
}

Even if LOG_USER should be fine for most users (it is available on
Windows too) methods allowing to change facility could be added, the
rest should be fine.

Could someone test if this would "work out of the box" on windows?

Cheers,
Thomas

NB: I'm not sure about the @'s in front of the syslog functions - as
syslog is working fine on all of my systems I never experienced
such an error ;-) If no one knows I'll test it - if there is even
one single scenario producing a PHP-notice they have to stay there.


Thomas Gelf schrieb:

Hi list,

as surely most of you have a lot of free time available I'll throw
in a new old topic to hopefully be discussed in this round ;-)

It's about logging. I like Zend_Log, it's well done - but the writers
currently available are not an option for most of my projects. Let's
make some example:

* stream writers writing to local files are running fine, are not
  blocking parallel requests and should be ok so far if you just
  want your logs to be written down somewhere

* it's difficult to set up a secure environment allowing PHP scripts
  running under different UIDs writing to the same log file (mostly
  leading to insecure logfile permissions or strange hacks)

* hacked PHP sites are able to modify (application) log entries if
  PHP is able to write to them

* if you want a cronjob to rotate log files for a PHP-written daemon
  you have to implement signal handlers (who has ever done so knows
  that this could be a really funny task)

* writing to DB is great for small projects - but impossible for sites
  with heavy traffic. If you want to handle high loads your application
  should be able to serve most requests without the need to connect to
  your database cluster

* ZF documentation should make people aware of locking and therefore
  performance issues when using MyISAM instead of InnoDB on MySQL

* who wants to achieve a distributed centralized logging is currently
  either forced to write it's own syslog writer or probably going to
  reimplement things syslog would usually do for you

Said all this: why is there still no Zend_Log_Writer_Syslog? Windows
is no excuse - PHP's syslog() function exists also there, so we should
be able to satisfy ZF's rules. And those rare windows people taking
care of their logs will surely be able to find out where they are going
to finish ;-) We should however avoid LOCAL*-facilities, as far as I
know (didn't test it) they are not available on windows.

Thanks for your feedback - and have a nice weekend!

Regards,
Thomas Gelf