diff --git a/src/scripts.php b/src/scripts.php index 7ddf316..4f28d20 100644 --- a/src/scripts.php +++ b/src/scripts.php @@ -1,18 +1,17 @@ register('logWriter', function ($c) use ($app) { - $logWriter = $app->config('log.writer'); - $file = $app->config('log.dir') . $app->config('log.file'); - - return is_object($logWriter) ? $logWriter : new \Leaf\LogWriter($file, $app->config('log.open') ?? true); + \Leaf\Config::addScript(function () { + \Leaf\Config::singleton('logWriter', function ($c) { + return is_object($c['log.writer']) ? + $c['log.writer'] : + new \Leaf\LogWriter($c['log.dir'] . $c['log.file'], $c['log.open'] ?? true); }); - $app->register('log', function ($c) use ($app) { - $log = new \Leaf\Log($c->logWriter); - $log->enabled($app->config('log.enabled')); - $log->level($app->config('log.level')); + \Leaf\Config::singleton('log', function ($c) { + $log = new \Leaf\Log(\Leaf\Config::get("logWriter")); + $log->enabled($c['log.enabled']); + $log->level($c['log.level']); return $log; });