Skip to content
Merged
Show file tree
Hide file tree
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
46 changes: 0 additions & 46 deletions apps/sim/lib/logs/console/logger.test.ts

This file was deleted.

62 changes: 4 additions & 58 deletions apps/sim/lib/logs/console/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,10 @@
*
* This module provides standardized console logging utilities for internal application logging.
* It is separate from the user-facing logging system in logging.ts.
*
* For Node.js runtime, uses TraceRoot logger for enhanced logging with trace correlation.
* For Edge runtime, falls back to console logging to avoid import errors.
*/
import chalk from 'chalk'
import { env } from '@/lib/env'

// Runtime detection - check if we're in Edge runtime
const isEdgeRuntime = () => {
return (
typeof window !== 'undefined' ||
(typeof globalThis !== 'undefined' && 'EdgeRuntime' in globalThis) ||
typeof process === 'undefined' ||
(typeof process !== 'undefined' && process.env.NEXT_RUNTIME === 'edge')
)
}

// Conditional TraceRoot import - only in Node runtime
let traceRootLogger: any = null

if (!isEdgeRuntime()) {
try {
const traceRoot = require('traceroot-sdk-ts')
traceRootLogger = traceRoot.getLogger
} catch (importError) {
console.warn('TraceRoot SDK not available, falling back to console logging')
}
}

/**
* LogLevel enum defines the severity levels for logging
*
Expand Down Expand Up @@ -133,29 +108,16 @@ const formatObject = (obj: any): string => {
*
* This class provides methods for logging at different severity levels
* and handles formatting, colorization, and environment-specific behavior.
* Uses TraceRoot logger in Node runtime and falls back to console logging in Edge runtime.
*/
export class Logger {
private module: string
private traceRootLoggerInstance: any = null

/**
* Create a new logger for a specific module
* @param module The name of the module (e.g., 'OpenAIProvider', 'AgentBlockHandler')
*/
constructor(module: string) {
this.module = module

// Initialize TraceRoot logger instance if available
if (traceRootLogger) {
try {
this.traceRootLoggerInstance = traceRootLogger(module)
} catch (error) {
console.warn(
`Failed to create TraceRoot logger for module ${module}, falling back to console logging`
)
}
}
}

/**
Expand Down Expand Up @@ -262,11 +224,7 @@ export class Logger {
* @param args Additional arguments to log
*/
debug(message: string, ...args: any[]) {
if (this.traceRootLoggerInstance) {
this.traceRootLoggerInstance.debug(message, ...args)
} else {
this.log(LogLevel.DEBUG, message, ...args)
}
this.log(LogLevel.DEBUG, message, ...args)
}

/**
Expand All @@ -284,11 +242,7 @@ export class Logger {
* @param args Additional arguments to log
*/
info(message: string, ...args: any[]) {
if (this.traceRootLoggerInstance) {
this.traceRootLoggerInstance.info(message, ...args)
} else {
this.log(LogLevel.INFO, message, ...args)
}
this.log(LogLevel.INFO, message, ...args)
}

/**
Expand All @@ -305,11 +259,7 @@ export class Logger {
* @param args Additional arguments to log
*/
warn(message: string, ...args: any[]) {
if (this.traceRootLoggerInstance) {
this.traceRootLoggerInstance.warn(message, ...args)
} else {
this.log(LogLevel.WARN, message, ...args)
}
this.log(LogLevel.WARN, message, ...args)
}

/**
Expand All @@ -326,11 +276,7 @@ export class Logger {
* @param args Additional arguments to log
*/
error(message: string, ...args: any[]) {
if (this.traceRootLoggerInstance) {
this.traceRootLoggerInstance.error(message, ...args)
} else {
this.log(LogLevel.ERROR, message, ...args)
}
this.log(LogLevel.ERROR, message, ...args)
}
}

Expand Down
1 change: 0 additions & 1 deletion apps/sim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"three": "0.177.0",
"traceroot-sdk-ts": "0.0.1-alpha.33",
"uuid": "^11.1.0",
"xlsx": "0.18.5",
"zod": "^3.24.2"
Expand Down
36 changes: 0 additions & 36 deletions apps/sim/traceroot.config.ts

This file was deleted.

Loading