$context */ public function debug(string $message, array $context = []): void { $this->write('debug', $message, $context); } /** @param array $context */ public function info(string $message, array $context = []): void { $this->write('info', $message, $context); } /** @param array $context */ public function warning(string $message, array $context = []): void { $this->write('warning', $message, $context); } /** @param array $context */ public function error(string $message, array $context = []): void { $this->write('error', $message, $context); } /** @param array $context */ public function critical(string $message, array $context = []): void { $this->write('critical', $message, $context); } /** @param array $arguments */ public function __call(string $level, array $arguments): void { $message = (string) ($arguments[0] ?? ''); $context = is_array($arguments[1] ?? null) ? $arguments[1] : []; $this->write($level, $message, $context); } /** @param array $context */ private function write(string $level, string $message, array $context): void { try { Log::channel($this->name)->{$level}($message, $context); } catch (Throwable $e) { $this->fallback($level, $message, $context, $e); } } /** @param array $context */ private function fallback(string $level, string $message, array $context, Throwable $e): void { $context['safe_log_channel'] = $this->name; $context['safe_log_error'] = $e->getMessage(); try { $default = (string) config('logging.default', 'stack'); if ($default !== '' && $default !== $this->name) { Log::channel($default)->warning($message, $context); return; } } catch (Throwable) { } try { error_log('['.$this->name.'] '.$level.': '.$message.' '.$e->getMessage()); } catch (Throwable) { } } }