ottaviano / messenger-logger-sender
LoggerSender for Symfony Messenger component
0.1.0
2018-11-03 18:06 UTC
Requires
- php: ^7.1.3
- psr/log: ^1.0
- symfony/messenger: ^4.2.0-dev
Requires (Dev)
- phpunit/phpunit: ^7.4
- symfony/var-dumper: ^4.1
This package is auto-updated.
Last update: 2024-10-29 05:28:33 UTC
README
LoggerSender requires a Psr\LoggerInterface
object, and can be used with monolog/monolog
lib for example which
provides a lot of handlers like StreamHandler
, RavenHandler
, SlackHandler
, etc.
Installation
composer require ottaviano/messenger-logger-sender
Beta
This lib is in Beta version as the component Messenger is in Beta too.
Example
Monolog & StreamHandler
$loggerSender = new \Ottaviano\Messenger\LoggerSender( new \Monolog\Logger( 'default', [ new \Monolog\Handler\StreamHandler(STDOUT), ] ) ); $middlewares = [ new \Symfony\Component\Messenger\Middleware\SendMessageMiddleware( new \Symfony\Component\Messenger\Transport\Sender\SendersLocator([ '*' => [$loggerSender], ]) ), ]; $bus = new \Symfony\Component\Messenger\MessageBus($middlewares); $message = new class { function __toString() { return 'Hey!'; } }; $bus->dispatch($message);
it will output:
[2018-11-03 18:26:26] default.INFO: Hey! {"message":"[object] (class@anonymous\u0000/Users/dimitri/Projects/test-messenger/script4.php0x101422223: Hey!)"} []