Implement proper log output

This commit is contained in:
Christopher Vagnetoft
2026-01-17 18:05:02 +01:00
parent b5de63e225
commit e3022469e7
2 changed files with 46 additions and 10 deletions

View File

@@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php
use Psr\Log\AbstractLogger;
require_once __DIR__."/../vendor/autoload.php";
$opts = getopt("hc:",["help","config:"],$optind);
@@ -11,6 +13,15 @@ $configFile = isset($opts['c'])
? $opts['config']
: null);
$logger = new class extends AbstractLogger
{
public function log($level, string|Stringable $message, array $context = []): void
{
printf("[%s] %s %s\n", $level, $message, $context?json_encode($context,JSON_UNESCAPED_SLASHES):'');
}
};
$daemon = (new NoccyLabs\Ntfi\NtfiDaemon())
->setLogger($logger)
->setConfigFile($configFile)
->start();