Skip to content

Instantly share code, notes, and snippets.

@emir
Created June 26, 2018 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emir/321c02acd35824c85e6c318923cf2cc7 to your computer and use it in GitHub Desktop.
Save emir/321c02acd35824c85e6c318923cf2cc7 to your computer and use it in GitHub Desktop.
<?php
namespace App\Loggers;
use Monolog\Formatter\LineFormatter;
class LocalLogger
{
public function __invoke($logger)
{
foreach ($logger->getHandlers() as $handler) {
$handler->setFormatter($this->getLogFormatter());
}
}
protected function getLogFormatter()
{
$format = str_replace(
'[%datetime%] ',
sprintf('[%%datetime%%] %s ', bin2hex(random_bytes(16)),
LineFormatter::SIMPLE_FORMAT
);
return new LineFormatter($format, null, true, true);
}
}
@duccio89
Copy link

duccio89 commented Oct 1, 2018

missing ):

correct syntax: bin2hex(random_bytes(16)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment