mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-13 18:52:18 +03:00
OmniRoute is an intelligent API gateway that unifies 20+ AI providers behind a single OpenAI-compatible endpoint. Features include intelligent routing with 6 strategies, multi-format translation (OpenAI/Claude/Gemini/Responses API), circuit breakers, semantic caching, combo fallback chains, real-time health monitoring, and a full dashboard with provider management, analytics, and CLI tool integration. Key highlights: - 20+ providers (Claude Code, Codex, Gemini CLI, GitHub Copilot, iFlow, Qwen, Kiro, etc.) - 6 routing strategies (Fill First, Round Robin, P2C, Random, Least Used, Cost Optimized) - Export/Import database backup with full archive support - Translator Playground with 4 modes (Playground, Chat Tester, Test Bench, Live Monitor) - 100% TypeScript across src/ and open-sse/ - Docker support with multi-stage builds - Comprehensive documentation and 9 dashboard screenshots
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
/**
|
|
* Structured Logger — Pino-based logger for OmniRoute
|
|
*
|
|
* Usage:
|
|
* import { logger } from "@/shared/utils/logger";
|
|
* const log = logger.child({ module: "proxy" });
|
|
* log.info({ model: "gpt-4o" }, "Request received");
|
|
* log.error({ err }, "Connection failed");
|
|
*
|
|
* In development, output is pretty-printed via pino-pretty.
|
|
* In production, output is structured JSON for log aggregation.
|
|
*/
|
|
import pino from "pino";
|
|
|
|
const isDev = process.env.NODE_ENV !== "production";
|
|
|
|
const baseConfig = {
|
|
level: process.env.LOG_LEVEL || (isDev ? "debug" : "info"),
|
|
base: { service: "omniroute" },
|
|
timestamp: pino.stdTimeFunctions.isoTime,
|
|
formatters: {
|
|
level(label) {
|
|
return { level: label };
|
|
},
|
|
},
|
|
};
|
|
|
|
// In development, use pino-pretty for human-readable output
|
|
const devTransport = isDev
|
|
? {
|
|
transport: {
|
|
target: "pino-pretty",
|
|
options: {
|
|
colorize: true,
|
|
translateTime: "HH:MM:ss.l",
|
|
ignore: "pid,hostname,service",
|
|
messageFormat: "[{module}] {msg}",
|
|
},
|
|
},
|
|
}
|
|
: {};
|
|
|
|
export const logger = pino({ ...baseConfig, ...devTransport });
|
|
|
|
/**
|
|
* Create a child logger with a module tag.
|
|
* @param {string} module - Module name for log context (e.g., "proxy", "db", "sse")
|
|
* @returns {pino.Logger}
|
|
*/
|
|
export function createLogger(module) {
|
|
return logger.child({ module });
|
|
}
|
|
|
|
export default logger;
|