From fc1ccbeb41471a9e0d4d916c9e7eb301b24b8abe Mon Sep 17 00:00:00 2001 From: Richard Hinkamp Date: Wed, 9 Jun 2021 21:19:38 +0200 Subject: [PATCH] Shutdown cb arg can be undefined + always return null --- lib/log4js.js | 5 ++++- types/log4js.d.ts | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/log4js.js b/lib/log4js.js index fdd48c8..e058597 100644 --- a/lib/log4js.js +++ b/lib/log4js.js @@ -111,7 +111,10 @@ function shutdown(cb) { if (shutdownFunctions === 0) { debug("No appenders with shutdown functions found."); - return cb !== undefined && cb(); + if (cb) { + cb(undefined); + } + return null; } appendersToCheck.filter(a => a.shutdown).forEach(a => a.shutdown(complete)); diff --git a/types/log4js.d.ts b/types/log4js.d.ts index 2fdc99c..560cc9d 100644 --- a/types/log4js.d.ts +++ b/types/log4js.d.ts @@ -9,7 +9,7 @@ export interface Log4js { addLayout(name: string, config: (a: any) => (logEvent: LoggingEvent) => string): void; connectLogger(logger: Logger, options: { format?: Format; level?: string; nolog?: any; }): any; // express.Handler; levels: Levels; - shutdown(cb: (error: Error) => void): void | null; + shutdown(cb?: (error: Error | undefined) => void): null; } export function getLogger(category?: string): Logger; @@ -23,7 +23,7 @@ export function connectLogger(logger: Logger, options: { format?: Format; level? export const levels: Levels; -export function shutdown(cb?: (error: Error) => void): void | null; +export function shutdown(cb?: (error: Error | undefined) => void): null; export interface BaseLayout { type: 'basic';