Implement proper log output
This commit is contained in:
11
bin/ntfid
11
bin/ntfid
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user