$config * * @return Logger */ public function __invoke(array $config): Logger { $service_type = is_string($config['service_type']) ? $config['service_type'] : 'default'; $level = $config['level'] instanceof Level ? $config['level'] : Level::Debug; $path = sprintf(storage_path(). "/logs/%s/%s.log", $service_type, $level->toPsrLogLevel()); $max_file = is_numeric($config['max_files']) ? (int) $config['max_files'] : 0; // Set Handler $handler = new RotatingFileHandler($path, $max_file, $level); $handler->setFormatter( new LineFormatter( "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n\n", 'Y-m-d H:i:s.u', true, true, true ) ); return new Logger($service_type, [$handler]); } }