/** * Open logs. * @return void */ public static function openLogs() { if (Daemon::$config->logging->value) { Daemon::$logpointer = fopen(Daemon::$config->logstorage->value, 'a'); if (isset(Daemon::$config->group->value)) { chgrp(Daemon::$config->logstorage->value, Daemon::$config->group->value); // @TODO: rewrite to async I/O } if (isset(Daemon::$config->user->value)) { chown(Daemon::$config->logstorage->value, Daemon::$config->user->value); // @TODO: rewrite to async I/O } if (Daemon::$process instanceof Thread\Worker && FileSystem::$supported) { FileSystem::open(Daemon::$config->logstorage->value, 'a!', function ($file) { Daemon::$logpointerAsync = $file; if (!$file) { return; } }); } } else { Daemon::$logpointer = null; Daemon::$logpointerAsync = null; } }