context.php: update LogDriver

This commit is contained in:
Zankaria 2024-10-04 12:57:37 +02:00
parent 79523f8251
commit 6132084b4b

View file

@ -1,9 +1,8 @@
<?php <?php
namespace Vichan; namespace Vichan;
use Vichan\Data\Driver\CacheDriver;
use Vichan\Data\{IpNoteQueries, ReportQueries, UserPostQueries}; use Vichan\Data\{IpNoteQueries, ReportQueries, UserPostQueries};
use Vichan\Data\Driver\{LogDriver, LogDrivers}; use Vichan\Data\Driver\{CacheDriver, ErrorLogLogDriver, FileLogDriver, LogDriver, StderrLogDriver, SyslogLogDriver};
defined('TINYBOARD') or exit; defined('TINYBOARD') or exit;
@ -41,15 +40,13 @@ function build_context(array $config): Context {
// Check 'syslog' for backwards compatibility. // Check 'syslog' for backwards compatibility.
if ((isset($config['syslog']) && $config['syslog']) || $backend === 'syslog') { if ((isset($config['syslog']) && $config['syslog']) || $backend === 'syslog') {
return LogDrivers::syslog($name, $level, $this->config['log_system']['syslog_stderr']); return new SyslogLogDriver($name, $level, $this->config['log_system']['syslog_stderr']);
} elseif ($backend === 'file') { } elseif ($backend === 'file') {
return LogDrivers::file($name, $level, $this->config['log_system']['file_path']); return new FileLogDriver($name, $level, $this->config['log_system']['file_path']);
} elseif ($backend === 'stderr') { } elseif ($backend === 'stderr') {
return LogDrivers::stderr($name, $level); return new StderrLogDriver($name, $level);
} elseif ($backend === 'none') {
return LogDrivers::none();
} else { } else {
return LogDrivers::error_log($name, $level); return new ErrorLogLogDriver($name, $level);
} }
}, },
CacheDriver::class => function($c) { CacheDriver::class => function($c) {