leftypol/inc/Data/Driver/Log/StderrLogDriver.php

28 lines
532 B
PHP
Raw Normal View History

2024-10-04 12:54:49 +02:00
<?php
2025-07-26 23:42:10 +02:00
namespace Vichan\Data\Driver\Log;
2024-10-04 12:54:49 +02:00
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");
}
}
}