Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 14x 1x 1x 14x 14x 14x 1x 1x 20x 20x 1x 1x 426x 426x 426x 426x 1x 1x 16x 16x 16x 16x 1x 1x 180x 180x 180x 180x 1x 1x 642x 642x 642x 642x 642x 642x 1x 1x 1x 14x 14x 14x | /**
* Logger Utility
*
* Simple logging utility for the BuildHive agent
*/
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
export interface Logger {
debug(message: string, ...args: any[]): void;
info(message: string, ...args: any[]): void;
warn(message: string, ...args: any[]): void;
error(message: string, ...args: any[]): void;
}
class SimpleLogger implements Logger {
private component: string;
private logLevel: LogLevel;
constructor(component: string, logLevel: LogLevel = 'info') {
this.component = component;
this.logLevel = logLevel;
}
debug(message: string, ...args: any[]): void {
if (this.shouldLog('debug')) {
console.debug(`[${new Date().toISOString()}] [DEBUG] [${this.component}] ${message}`, ...args);
}
}
info(message: string, ...args: any[]): void {
if (this.shouldLog('info')) {
console.info(`[${new Date().toISOString()}] [INFO] [${this.component}] ${message}`, ...args);
}
}
warn(message: string, ...args: any[]): void {
if (this.shouldLog('warn')) {
console.warn(`[${new Date().toISOString()}] [WARN] [${this.component}] ${message}`, ...args);
}
}
error(message: string, ...args: any[]): void {
if (this.shouldLog('error')) {
console.error(`[${new Date().toISOString()}] [ERROR] [${this.component}] ${message}`, ...args);
}
}
private shouldLog(level: LogLevel): boolean {
const levels: LogLevel[] = ['debug', 'info', 'warn', 'error'];
const currentLevelIndex = levels.indexOf(this.logLevel);
const messageLevelIndex = levels.indexOf(level);
return messageLevelIndex >= currentLevelIndex;
}
}
export function createLogger(component: string, logLevel?: LogLevel): Logger {
const level = logLevel || (process.env.BUILDHIVE_LOG_LEVEL as LogLevel) || 'info';
return new SimpleLogger(component, level);
} |