UNPKG

agentlang

Version:

The easiest way to build the most reliable AI agents - enterprise-grade teams of AI agents that collaborate with each other and humans

43 lines 1.25 kB
import { isNodeEnv } from '../utils/runtime.js'; let DailyRotateFile; let winston; if (isNodeEnv) { // Only import Node.js modules in Node environment // Using dynamic imports to avoid breaking browser bundling await import('winston-daily-rotate-file').then(module => { DailyRotateFile = module.default; }); await import('winston').then(module => { winston = module.default; }); } export let logger; if (isNodeEnv) { const fileTransport = new DailyRotateFile({ level: 'debug', filename: 'logs/app-%DATE%.log', datePattern: 'YYYY-MM-DD', maxSize: '20m', maxFiles: '7d', }); logger = winston.createLogger({ format: winston.format.combine(winston.format.timestamp(), winston.format.printf(({ timestamp, level, message }) => { return `[${timestamp}] ${level}: ${message}`; })), transports: [fileTransport], }); } else { function mkLogger(tag) { return (msg) => { console.log(`${tag}: ${msg}`); }; } logger = { debug: mkLogger('DEBUG'), info: mkLogger('INFO'), warn: mkLogger('WARN'), error: mkLogger('ERROR'), }; } //# sourceMappingURL=logger.js.map