nicktacular / php-mongo-session

A PHP session handler with a Mongo DB backend.
MIT License
18 stars 6 forks source link

update logging output to be parseable/consistent #21

Open rocksfrow opened 9 years ago

rocksfrow commented 9 years ago

@nicktacular do you have any objections to modifying the basic logging output to be delmiter-based -- or structured consistently in some way so it's parse-able?

I'd like to import my session logging into my logstash server so I can monitor average lock wait times, expired lock waits, etc via my ELK stack (elasticsearch+logstash+kibana).

But I cannot control the output entirely via the current 'logger' configuration. It would be best if the ->log() function were to pass raw name/value pairs for example so I can handle them properly from mongo_logger() (my function).

I guess I could just explode(':', $msg) on the message that is coming in, but even that won't work consistently because some of the log messages are just random strings.

I am thinking basically we break $msg apart into two inputs.

So you would have something like;

$this->log('lock_wait_exceeded','.3502s');

Instead of:

$this->log('LOCK_WAIT_EXCEEDED:.3502s');

Maybe the generic messages like 'Lock acquired @ ...' would simply be given an action of 'message' or something like that.

Again something like,

$this->log('message','Lock acquired @ xxxx');

Instead of

$this->log('Lock acquired @ xxxx');

This way your logger function can actually handle the parameters separately.

Perhaps we might need to add a way for it to be backwards compatible, so maybe add them as optional params.

IE,

function log($msg, $priority=10, $opts=array()){
nicktacular commented 9 years ago

Sure thing. But I'd like to merge my testing branch into master first. On Mar 4, 2015 10:51 PM, "Kyle Renfrow" notifications@github.com wrote:

@nicktacular https://github.com/nicktacular do you have any objections to modifying the basic logging output to be delmiter-based -- or structured consistently in some way so it's parse-able?

I'd like to import my session logging into my logstash server so I can monitor average lock wait times, expired lock waits, etc via my ELK stack (elasticsearch+logstash+kibana).

But I cannot control the output entirely via the current 'logger' configuration. It would be best if the ->log() function were to pass raw name/value pairs for example so I can handle them properly from mongo_logger() (my function).

I guess I could just explode(':', $msg) on the message that is coming in, but even that won't work consistently because some of the log messages are just random strings.

I am thinking basically we break $msg apart into two inputs.

So you would have something like;

$this->log('lock_wait_exceeded','.3502s');

Instead of:

$this->log('LOCK_WAIT_EXCEEDED:.3502s');

Maybe the generic messages like 'Lock acquired @ ...' would simply be given an action of 'message' or something like that.

Again something like,

$this->log('message','Lock acquired @ xxxx');

Instead of

$this->log('Lock acquired @ xxxx');

This way your logger function can actually handle the parameters separately.

Perhaps we might need to add a way for it to be backwards compatible, so maybe add them as optional params.

IE,

function log($msg, $priority=10, $opts=array()){

— Reply to this email directly or view it on GitHub https://github.com/nicktacular/php-mongo-session/issues/21.