/**
 * 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);
}
