Skip to content
Merged
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
28 changes: 28 additions & 0 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Application logger utility
type LogLevel = 'debug' | 'info' | 'warn' | 'error';

const LOG_COLORS: Record<LogLevel, string> = {
debug: 'color: #9CA3AF',
info: 'color: #3B82F6',
warn: 'color: #F59E0B',
error: 'color: #EF4444',
};

class Logger {
private isDev = import.meta.env?.DEV ?? true;
Copy link

@cubic-dev-ai cubic-dev-ai bot Mar 5, 2026

Choose a reason for hiding this comment

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

P2: isDev falls back to true, which can unintentionally enable debug logs outside development when env metadata is unavailable.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/utils/logger.ts, line 12:

<comment>`isDev` falls back to `true`, which can unintentionally enable debug logs outside development when env metadata is unavailable.</comment>

<file context>
@@ -0,0 +1,28 @@
+};
+
+class Logger {
+  private isDev = import.meta.env?.DEV ?? true;
+
+  private log(level: LogLevel, message: string, data?: unknown): void {
</file context>
Suggested change
private isDev = import.meta.env?.DEV ?? true;
private isDev = import.meta.env?.DEV ?? false;
Fix with Cubic


private log(level: LogLevel, message: string, data?: unknown): void {
if (!this.isDev && level === 'debug') return;
const timestamp = new Date().toISOString().slice(11, 23);
const prefix = '[' + timestamp + '] [' + level.toUpperCase() + ']';
if (data) { console.log('%c' + prefix + ' ' + message, LOG_COLORS[level], data); }
Copy link

@cubic-dev-ai cubic-dev-ai bot Mar 5, 2026

Choose a reason for hiding this comment

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

P2: Falsy payload values are silently dropped because data is checked with truthiness instead of undefined presence.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/utils/logger.ts, line 18:

<comment>Falsy payload values are silently dropped because `data` is checked with truthiness instead of `undefined` presence.</comment>

<file context>
@@ -0,0 +1,28 @@
+    if (!this.isDev && level === 'debug') return;
+    const timestamp = new Date().toISOString().slice(11, 23);
+    const prefix = '[' + timestamp + '] [' + level.toUpperCase() + ']';
+    if (data) { console.log('%c' + prefix + ' ' + message, LOG_COLORS[level], data); }
+    else { console.log('%c' + prefix + ' ' + message, LOG_COLORS[level]); }
+  }
</file context>
Fix with Cubic

else { console.log('%c' + prefix + ' ' + message, LOG_COLORS[level]); }
}

debug(msg: string, data?: unknown) { this.log('debug', msg, data); }
info(msg: string, data?: unknown) { this.log('info', msg, data); }
warn(msg: string, data?: unknown) { this.log('warn', msg, data); }
error(msg: string, data?: unknown) { this.log('error', msg, data); }
}

export const logger = new Logger();
Loading