dynamixel
Version:
Node.js library for controlling DYNAMIXEL servo motors via U2D2 interface with Protocol 2.0 support
146 lines (145 loc) • 4 kB
TypeScript
/**
* Enhanced Logger for DYNAMIXEL library
* Inspired by DynaNode's Logger architecture
* Provides structured logging with performance metrics and filtering
*/
export class Logger extends EventEmitter<[never]> {
constructor(options?: {});
level: any;
enableConsole: boolean;
enableFile: any;
maxLogEntries: any;
enablePerformanceMetrics: any;
logLevels: {
trace: number;
debug: number;
info: number;
warn: number;
error: number;
fatal: number;
};
logs: any[];
performanceMetrics: Map<any, any>;
logCount: {
trace: number;
debug: number;
info: number;
warn: number;
error: number;
fatal: number;
};
setupFormatters(): void;
formatters: {
console: (entry: any) => string;
json: (entry: any) => string;
structured: (entry: any) => {
timestamp: any;
level: any;
message: any;
deviceId: any;
category: any;
data: any;
performance: any;
};
} | undefined;
/**
* Check if a log level should be output
*/
shouldLog(level: any): boolean;
/**
* Core logging method
*/
log(level: any, message: any, data?: {}): void;
outputToConsole(entry: any): void;
trace(message: any, data: any): void;
debug(message: any, data: any): void;
info(message: any, data: any): void;
warn(message: any, data: any): void;
error(message: any, data: any): void;
fatal(message: any, data: any): void;
/**
* Protocol-specific logging methods
*/
logProtocol(direction: any, deviceId: any, packet: any, timing: any): void;
logPacketSent(deviceId: any, instruction: any, parameters: any, timing: any): void;
logPacketReceived(deviceId: any, packet: any, timing: any): void;
/**
* Connection logging
*/
logConnection(event: any, connectionType: any, details?: {}): void;
/**
* Device discovery logging
*/
logDiscovery(event: any, details?: {}): void;
/**
* Performance tracking
*/
startPerformanceTimer(operation: any, context?: {}): string;
endPerformanceTimer(timerId: any, additionalData?: {}): {
operation: any;
duration: number;
context: any;
} | null;
/**
* Measure function execution time
*/
measureAsync(operation: any, fn: any, context?: {}): Promise<any>;
measure(operation: any, fn: any, context?: {}): any;
/**
* Get filtered logs
*/
getLogs(filters?: {}): any[];
/**
* Get log statistics
*/
getStatistics(): {
totalLogs: number;
logCounts: {
trace: number;
debug: number;
info: number;
warn: number;
error: number;
fatal: number;
};
categories: {};
devices: {};
recentErrors: any[];
timeSpan: {
start: any;
end: any;
} | null;
};
/**
* Export logs
*/
exportLogs(format?: string, filters?: {}): string;
/**
* Clear logs
*/
clearLogs(): void;
/**
* Set log level
*/
setLevel(level: any): void;
/**
* Create a child logger with context
*/
child(context?: {}): any;
/**
* Device-specific logger
*/
forDevice(deviceId: any): any;
/**
* Category-specific logger
*/
forCategory(category: any): any;
}
export const logger: Logger;
export function trace(message: any, data: any): void;
export function debug(message: any, data: any): void;
export function info(message: any, data: any): void;
export function warn(message: any, data: any): void;
export function error(message: any, data: any): void;
export function fatal(message: any, data: any): void;
import { EventEmitter } from 'events';