-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logger\Formatter\Line::setDateFormat does not support microseconds #2893
Comments
i solved it with a separate class which inherits from \Phalcon\Logger\Formatter\Line class LogFormatter extends \Phalcon\Logger\Formatter\Line {
public function format($message, $type, $timestamp, $context ) {
$dateTime = new \DateTime;
$dateTime->setTimestamp($timestamp);
$dateFormat = str_replace('u', floor((microtime(true) - $timestamp) * 1000), $this->getDateFormat());
$formated = str_replace('%date%', $dateTime->format( $dateFormat ), $this->getFormat() );
$formated = str_replace('%message%', $message, $formated);
return str_replace('%type%', $this->getTypeString($type), $formated) . "\n";
}
} Strange thing is, that toward the php documentation DateTime::format() does not give me the micreconds! All in all it works fine for me. |
It would be nice to see a millisecond in the logs out of the box without the extension adapter. |
@stdnk Did you try by setting the date format when constructing the formatter? Internally it uses the
and as a result you could do this:
|
Nevermind I just noticed your findings in the first message. This should be changed to use the object vs the function. |
when i use
i only get 000000 for the microseconds (look at the ".u" in the setDateFormat)
i get something like this: [13:51:10.000000]
PHP-Documentation at http://de2.php.net/manual/en/function.date.php says: Note that date() will always generate 000000 since it takes an integer parameter, whereas DateTime::format() does support microseconds.
Aha, is the phalcon-method setDateFormat() only a wrapper to the native Date()-function?
I want to get the microseconds in the log at the "correct" place, what can do?
Swen
The text was updated successfully, but these errors were encountered: