From 0b87f5516a4d6f0fc82c84ea3b3fa47ec6605a31 Mon Sep 17 00:00:00 2001 From: Tiara Rodney Date: Fri, 13 Mar 2026 22:42:52 +0100 Subject: [PATCH] fix(formatter,manager): add Formatter.format(), fix Placeholder access Add format() method to Formatter class to delegate to the style's format method. Change Placeholder.loggers to public so Manager can access it for hierarchy fixup. --- src/formatter.ts | 14 ++++++++++++++ src/manager.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/formatter.ts b/src/formatter.ts index 7e0197c..cf1d6e6 100644 --- a/src/formatter.ts +++ b/src/formatter.ts @@ -174,6 +174,20 @@ export class Formatter { * formatters, for example if you want all logging times to be shown in GMT, * set the 'converter' attribute in the Formatter class. */ + /** + * Format the specified record as text. + * + * The record's attribute dictionary is used as the operand to a string + * formatting operation which yields the returned string. Before the + * formatting operation, a couple of preparatory steps are carried out. + * The message attribute of the record is computed using LogRecord.getMessage(). + * If the formatting string uses the time, formatTime() is called to format + * the event time. + */ + format(record: LogRecord): string { + return this.style.format(record); + } + formatTime(record: LogRecord, datefmt?: any): string { //TODO: record.created diff --git a/src/manager.ts b/src/manager.ts index 32bc8c5..1d6828d 100644 --- a/src/manager.ts +++ b/src/manager.ts @@ -22,7 +22,7 @@ var loggerClass = Logger; * Placeholder instance */ class Placeholder { - protected loggers: Logger[] = []; + public loggers: Logger[] = []; /** * initialize with the specified logger being a child of this placeholder.