Move src/ → apps/server/ and packages/web/ → apps/web/ to adopt standard monorepo conventions (apps/ for runnable apps, packages/ for reusable libraries). Update all config files, shared package imports, test fixtures, and documentation to reflect new paths. Key fixes: - Update workspace config to ["apps/*", "packages/*"] - Update tsconfig.json rootDir/include for apps/server/ - Add apps/web/** to vitest exclude list - Update drizzle.config.ts schema path - Fix ensure-schema.ts migration path detection (3 levels up in dev, 2 levels up in dist) - Fix tests/integration/cli-server.test.ts import paths - Update packages/shared imports to apps/server/ paths - Update all docs/ files with new paths
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
/**
|
|
* Logging Module
|
|
*
|
|
* File-based logging infrastructure for per-process stdout/stderr capture.
|
|
*/
|
|
|
|
// Types
|
|
export type { LogLevel, LogEntry, LogConfig, LogStream } from './types.js';
|
|
|
|
// Classes
|
|
export { LogManager } from './manager.js';
|
|
export { ProcessLogWriter } from './writer.js';
|
|
|
|
// Convenience functions
|
|
import { LogManager } from './manager.js';
|
|
import { ProcessLogWriter } from './writer.js';
|
|
import type { EventBus } from '../events/index.js';
|
|
|
|
/**
|
|
* Creates a new ProcessLogWriter with default configuration.
|
|
*
|
|
* Convenience function for common use case of creating a log writer
|
|
* for a specific process using default log directory (~/.cw/logs).
|
|
*
|
|
* @param processId - Unique identifier for the process
|
|
* @param eventBus - Optional EventBus for emitting log entry events
|
|
* @returns A new ProcessLogWriter instance (call open() before writing)
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* const writer = createLogger('agent-001');
|
|
* await writer.open();
|
|
* await writer.writeStdout('Hello from agent\n');
|
|
* await writer.close();
|
|
* ```
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* // With event bus for real-time streaming
|
|
* const bus = createEventBus();
|
|
* const writer = createLogger('agent-001', bus);
|
|
* bus.on('log:entry', (event) => console.log(event.payload));
|
|
* await writer.open();
|
|
* await writer.writeStdout('Hello from agent\n');
|
|
* ```
|
|
*/
|
|
export function createLogger(processId: string, eventBus?: EventBus): ProcessLogWriter {
|
|
const manager = new LogManager();
|
|
return new ProcessLogWriter(processId, manager, eventBus);
|
|
}
|