ts-tiny-logger
Version:
A lightweight TypeScript logger package with Flyweight pattern
47 lines (46 loc) • 1.3 kB
TypeScript
import { LogEntry, ILogger } from './types';
/**
* A simple logger class that implements the Flyweight pattern
* to allow for multiple logger instances
*/
export declare class Logger implements ILogger {
private logs;
private static instances;
/**
* Private constructor to prevent direct instantiation
*/
private constructor();
/**
* Get a logger instance with the given identifier
* If an instance with this identifier already exists, it will be returned
* Otherwise, a new instance will be created
*
* @param identifier - Unique identifier for the logger instance
* @returns Logger instance
*/
static getInstance(identifier: string): Logger;
/**
* Add a new log entry
*
* @param name - Name or category of the log
* @param value - Value or message to be logged
*/
log(name: string, value: string): void;
/**
* Get all log entries
*
* @returns Array of log entries
*/
getLogs(): LogEntry[];
/**
* Clear all log entries
*/
clearLogs(): void;
/**
* Format date and time to 'YYYY-MM-DD:hh-mm-ss-ms' format
*
* @param date - Date object to format
* @returns Formatted date and time string
*/
private formatDateTime;
}