Revert "feat(traceroot): add traceroot logger" (#1434)

This reverts commit 6d1b172a3e.
This commit is contained in:
Vikhyath Mondreti
2025-09-23 16:59:49 -07:00
committed by GitHub
parent 603b5471a3
commit aa0a33e60f
6 changed files with 217 additions and 923 deletions
-46
View File
@@ -1,46 +0,0 @@
import { beforeEach, describe, expect, test, vi } from 'vitest'
vi.unmock('@/lib/logs/console/logger')
import { createLogger, Logger } from '@/lib/logs/console/logger'
describe('Logger', () => {
let logger: Logger
beforeEach(() => {
logger = new Logger('TestModule')
})
describe('class instantiation', () => {
test('should create logger instance', () => {
expect(logger).toBeDefined()
expect(logger).toBeInstanceOf(Logger)
})
})
describe('createLogger factory function', () => {
test('should create logger instance', () => {
const factoryLogger = createLogger('FactoryModule')
expect(factoryLogger).toBeDefined()
expect(factoryLogger).toBeInstanceOf(Logger)
})
})
describe('logging methods', () => {
test('should have debug method', () => {
expect(typeof logger.debug).toBe('function')
})
test('should have info method', () => {
expect(typeof logger.info).toBe('function')
})
test('should have warn method', () => {
expect(typeof logger.warn).toBe('function')
})
test('should have error method', () => {
expect(typeof logger.error).toBe('function')
})
})
})
+4 -58
View File
@@ -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
*
@@ -133,11 +108,9 @@ 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
@@ -145,17 +118,6 @@ export class Logger {
*/
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`
)
}
}
}
/**
@@ -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)
}
/**
@@ -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)
}
/**
@@ -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)
}
/**
@@ -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)
}
}
-1
View File
@@ -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"
-36
View File
@@ -1,36 +0,0 @@
import type { TraceRootConfigFile } from 'traceroot-sdk-ts'
const config: TraceRootConfigFile = {
// Basic service configuration
service_name: 'sim',
github_owner: 'simstudioai',
github_repo_name: 'sim',
github_commit_hash: 'staging',
// Your environment configuration such as development, staging, production
environment: process.env.NODE_ENV || 'development',
// Token configuration
// This is the token you can generate from the TraceRoot.AI website
token: 'traceroot-*',
// Whether to enable console export of spans and logs
enable_span_console_export: false,
enable_log_console_export: true,
// Whether to enable cloud export of spans and logs
enable_span_cloud_export: false,
enable_log_cloud_export: false,
// Log level
log_level: process.env.NODE_ENV === 'production' ? 'info' : 'debug',
// Local mode that whether to store all TraceRoot data locally
// and allow traceroot platform serving locally
// This requires Jaeger to be installed and running
local_mode: false,
// Whether to auto-initialize the traceroot SDK
autoInit: true,
}
export default config
+213 -781
View File
File diff suppressed because it is too large Load Diff
-1
View File
@@ -46,7 +46,6 @@
"react-colorful": "5.6.1",
"remark-gfm": "4.0.1",
"socket.io-client": "4.8.1",
"traceroot-sdk-ts": "0.0.1-alpha.35",
"twilio": "5.9.0"
},
"devDependencies": {