/** * Registra el servicio * * @param Api $app Instancia de la aplicacion * * @return void */ public static function register(Api $app) { $container = $app->getContainer(); $loggerConfig = $container->get('loggy'); $loggers = new LoggerCollection(); foreach ($loggerConfig as $channel => $channelConfig) { $handlers = []; foreach ($channelConfig as $handlerConfig) { extract($handlerConfig); $handlers[] = (new $handler($level))->config($config); } $loggers->set($channel, new Logger($channel, $handlers)); } $container['logger'] = $loggers; }
/** * Registra el servicio * * @param Api $app Instancia de la aplicacion * * @return void */ public static function register(Api $app) { $container = $app->getContainer(); $loggerConfig = $container->get('monolog'); $loggers = new LoggerCollection(); foreach ($loggerConfig as $channel => $channelConfig) { $logger = new Logger($channel); foreach ($channelConfig as $handlerConfig) { extract($handlerConfig); $logger->pushHandler(new $handler($config['output'], $level)); } $loggers->set($channel, $logger); } $container['logger'] = $loggers; }