Best way to implement logging?

Visto 132 veces
Saltar al primer mensaje no leído

Raffael Luthiger

no leída,
22 ene 2014, 9:40:1822/1/14
a sabredav...@googlegroups.com
Hi,

Is there already a logging class implemented which I could use? Or what is the best way to implement some logging. I would like to log when someone tries to log in with the wrong password etc.

Regards,

Raffael

Evert Pot

no leída,
26 ene 2014, 20:18:3326/1/14
a sabredav...@googlegroups.com
Hello Raffael,

It kinda depends on what you are trying to log, but most actions can be intercepted by using the event system.

I've started work on a debug plugin, specifically for that purpose. Haven't had a lot of time to dig into it though. You can find it here:

https://github.com/fruux/sabre-dav/blob/debugplugin/lib/Sabre/DAV/DebugPlugin.php

Most events are described on the wiki. Keep in mind that most of the events will change in the upcoming sabredav release though:

http://code.google.com/p/sabredav/wiki/WritingPlugins

Hope this helps,
Evert

Raffael Luthiger

no leída,
27 ene 2014, 8:23:4827/1/14
a sabredav...@googlegroups.com
Hi Evert,

Thanks for the links. This will help me a lot.

I have some random remarks:

- In the DebugPlugin you do not define how many log levels you have.
- Due to the parameters which have to be given in the constructor the plugin can only be used for writing log files. It would not be possible to create a DebugPlugin with a database-based backend. It would be cool if there would be a "backend-neutral" interface which your debug plugin implements. Then other programmers could easily create other debug plugins.
- On the WritingPlugins wiki page it is nowhere written if the initialize method is really needed or not and when exactly it is invoked and with which parameters.
- On the same page it says "beforeMethod is called whenever any http method handler is called.". Wouldn't it be better to write "beforeMethod is called right before a http method handler is called."? Or does it not happen right before the http method is called?
- It would be good as well if this page answers as well the question what happens when serveral methods are subscribed to the same event. E.g:

$server->subscribeEvent('beforeMethod','foo');
$server->subscribeEvent('beforeMethod','bar');
In what order will they be called etc.

These are just a few questions that came to my mind when reading the two pages. It would be great if you would find the time to update the wiki page etc.

But thanks for the work so far.

Raffael


--
You received this message because you are subscribed to a topic in the Google Groups "SabreDAV Discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sabredav-discuss/VdxDv7GLcvo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sabredav-discu...@googlegroups.com.
To post to this group, send email to sabredav...@googlegroups.com.
Visit this group at http://groups.google.com/group/sabredav-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Evert Pot

no leída,
27 ene 2014, 16:18:3527/1/14
a sabredav...@googlegroups.com
Hi Raffael,

I just realized that the version on github was older. I had a newer copy on my laptop, which I've just pushed.
Some comments below:


On Monday, January 27, 2014 8:23:48 AM UTC-5, Raffael Luthiger wrote:
Hi Evert,

Thanks for the links. This will help me a lot.

I have some random remarks:

- In the DebugPlugin you do not define how many log levels you have.
- Due to the parameters which have to be given in the constructor the plugin can only be used for writing log files. It would not be possible to create a DebugPlugin with a database-based backend. It would be cool if there would be a "backend-neutral" interface which your debug plugin implements. Then other programmers could easily create other debug plugins.

Because we're using psr/log, this is now possible :) SabreDAV will not provide any default backend, so it is recommended to use something like monolog (https://github.com/Seldaek/monolog).
 
- On the WritingPlugins wiki page it is nowhere written if the initialize method is really needed or not and when exactly it is invoked and with which parameters.

I'll give this page an overhaul for the next release. This is a good point though. Not everything will be 100% documented in the wiki, most stuff will have to be inferred from source.
Here can be seen that is indeed required and it only has one parameter:

https://github.com/fruux/sabre-dav/blob/master/lib/Sabre/DAV/ServerPlugin.php#L27
 
- On the same page it says "beforeMethod is called whenever any http method handler is called.". Wouldn't it be better to write "beforeMethod is called right before a http method handler is called."? Or does it not happen right before the http method is called?
- It would be good as well if this page answers as well the question what happens when serveral methods are subscribed to the same event. E.g:

$server->subscribeEvent('beforeMethod','foo');
$server->subscribeEvent('beforeMethod','bar');
In what order will they be called etc.

The upcoming release changes a lot of stuff related to event management. This particular bit is pushed to a new component. Detailed documentation is here:

https://github.com/fruux/sabre-event

In short:

1. Now use 'on' instead of 'subscribeEvent'
2. Multiple event handlers are indeed allowed
3. No guarantee is given for the order.
4. Unless you specify the third argument, $priority. Lower priority is earlier.


These are just a few questions that came to my mind when reading the two pages. It would be great if you would find the time to update the wiki page etc.

I'll work on a new version this afternoon =)

Evert

Raffael Luthiger

no leída,
28 ene 2014, 11:17:1628/1/14
a sabredav...@googlegroups.com
Hi Evert,

Thanks for the fast reply. It is really great to see that all changes in the new Debug file.

Will there be soon a new SabreDAV release where it is included?

Thanks,
Raffael



--

Evert Pot

no leída,
3 feb 2014, 21:33:313/2/14
a sabredav...@googlegroups.com

On Tuesday, January 28, 2014 11:17:16 AM UTC-5, Raffael Luthiger wrote:
Hi Evert,

Thanks for the fast reply. It is really great to see that all changes in the new Debug file.

Will there be soon a new SabreDAV release where it is included?

It would be nice to include it in the next major version. But it depends on if we have enough time to finish it.


Evert

Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos