-
I am using the Logger plugin to send logs from PHP to the RoadRunner server. Everything works OK, but I do have a couple of questions: In my RR server configuration the logger plugin is configured like this:
On the PHP side I am using Monolog with a custom handler that sends messages to the RR server final class RoadRunnerHandler extends AbstractProcessingHandler
{
public const FORMAT = "%channel%: %message% %context% %extra%\n";
public function __construct(
private readonly RoadRunnerLogger $logger,
) {
parent::__construct();
$this->setFormatter(new LineFormatter(self::FORMAT));
}
protected function write(LogRecord $record): void
{
$message = $record['formatted'];
assert(is_string($message) || $message instanceof Stringable);
$level = $record['level'] instanceof Level ? $record['level']->value : $record['level'];
match ($level) {
LogLevel::ERROR, LogLevel::CRITICAL, LogLevel::ALERT, LogLevel::EMERGENCY => $this->logger->error($message),
LogLevel::WARNING => $this->logger->warning($message),
LogLevel::INFO, LogLevel::NOTICE => $this->logger->info((string) $message),
default => $this->logger->debug($message),
};
}
} This is pretty much a tweaked implementation of the RoadRunner Handler in the Spiral Framework. The app logs being produced by the RR server look something like this in production:
In development app logs look something like:
So finally, my questions are:
Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @shieldz80 👋
|
Beta Was this translation helpful? Give feedback.
Hey @shieldz80 👋
app main
, but a color code. Because logs in the development mode are colored. So, as in previous answers, everything is possible if you fork logger plugin and tune it for yourself: https://docs.roadrunner.dev/docs/customization/build