fluent / fluent-logger-php

A structured logger for Fluentd (PHP)
Other
215 stars 57 forks source link

Breaking MongoDate #28

Closed vasi-grigo closed 9 years ago

vasi-grigo commented 9 years ago

hello using fluent-logger-php and encountering the following issue when using it with mongodb:

php:

$a = new \MongoDate();
$logger->post('someTag', ['a' => $a]);

yields:

    "a" : {
        "sec" : 1418898182,
        "usec" : 0
    }

Object type is lost. Should it not be something like {"a" : ISODate("2014-12-18T10:23:03Z")} ?

thank you for the work you've done, cheers

xprom commented 9 years ago

$a = new \MongoDate(); var_dump($a);

object(MongoDate)[5] public 'sec' => int 1418904741 public 'usec' => int 929000

xprom commented 9 years ago

Fluent don't know about MongoDate and other SomeDateClass and it's correct

vasi-grigo commented 9 years ago

the yield part is from MongoDB via console naturally, if var_dump is done in php right after instantiation - it will show MongoDate in PHP but you would want it transferred into mongo preserved as ISODate because the latter offers a lot of nice features

xprom commented 9 years ago

I think it's a problem of MongoData. For exemple: Today i send data throw fluent to mongo. Tomorrow i can change matching to Mysql. Fluent work with abstract platform.

xprom commented 9 years ago

Please. Look at https://github.com/fluent/fluent-logger-php/blob/master/src/Fluent/Logger/JsonPacker.php

all data is packed to json

for exemple run: $d = new MongoDate(); var_dump(json_encode($d)); exit();

json doesn't content any information about MongoDate(), Date(), PsqlDate() etc. try to send timestamp

vasi-grigo commented 9 years ago

yes, probably this is more of an improvement for the mongo fluentd plugin; not fluentd or fluent-logger-php thanks for the help