Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/lib/logEnv.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import path from "path";

const DEFAULT_APP_LOG_RETENTION_DAYS = 7;
// DATA_DIR is the project root for local installs or ~/.omniroute/ for global CLI.
// Fall back to cwd so existing setups don't break silently.
const appRoot = process.env.DATA_DIR || process.cwd();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If process.env.DATA_DIR is set to a relative path or contains whitespace, it may resolve inconsistently compared to how DATA_DIR is handled in src/lib/dataPaths.ts (which trims and resolves paths using path.resolve). Resolving it to an absolute path ensures the log path is always absolute and robust.

Suggested change
const appRoot = process.env.DATA_DIR || process.cwd();
const appRoot = process.env.DATA_DIR && process.env.DATA_DIR.trim() ? path.resolve(process.env.DATA_DIR.trim()) : process.cwd();

const DEFAULT_APP_LOG_PATH = path.join(appRoot, "logs", "application", "app.log");
Comment on lines +5 to +6

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the Repository Style Guide (Rule 2.9), any changes to production code (such as files in src/) must be accompanied by corresponding tests. Please add or update unit tests to cover this new log path resolution logic.

References
  1. Always include tests when changing production code (src/, open-sse/, electron/, bin/). (link)

const DEFAULT_CALL_LOG_RETENTION_DAYS = 7;
const DEFAULT_APP_LOG_MAX_SIZE = 50 * 1024 * 1024;
const DEFAULT_APP_LOG_MAX_FILES = 20;
const DEFAULT_CALL_LOG_MAX_ENTRIES = 10000;
const DEFAULT_CALL_LOGS_TABLE_MAX_ROWS = 100000;
const DEFAULT_CALL_LOG_PIPELINE_MAX_SIZE_KB = 512;
const DEFAULT_PROXY_LOGS_TABLE_MAX_ROWS = 100000;
const DEFAULT_APP_LOG_PATH = path.join(process.cwd(), "logs", "application", "app.log");


function parsePositiveInt(value: string | undefined, fallback: number): number {
if (!value) return fallback;
Expand Down