log-driver.php: split up log driver

This commit is contained in:
Zankaria committed 2024-10-04 20:16:04 +02:00
1 parent 5dab17e5f4
commit 36d48951c1
7 files changed
+198 -189

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
<?php
namespace Vichan\Data\Driver;
defined('TINYBOARD') or exit;
/**
* Log to php's standard error file stream.
*/
class StderrLogDriver implements LogDriver {
use LogTrait;
private string $name;
private int $level;
public function __construct(string $name, int $level) {
$this->name = $name;
$this->level = $level;
}
public function log(int $level, string $message): void {
if ($level <= $this->level) {
$lv = $this->levelToString($level);
\fwrite(\STDERR, "{$this->name} $lv: $message\n");
}
}
}