From 3d529acf2a2a64d59e27b9a02289dcbc00a58c64 Mon Sep 17 00:00:00 2001 From: xinbenlv Date: Mon, 11 Mar 2019 21:49:06 -0700 Subject: [PATCH 1/5] Allow anything in the addLayout per # Adding your own layouts You can add your own layouts by calling `log4js.addLayout(type, fn)` before calling `log4js.configure`. `type` is the label you want to use to refer to your layout in appender configuration. `fn` is a function that takes a single object argument, which will contain the configuration for the layout instance, and returns a layout function. A layout function takes a log event argument and **returns a string (usually, although you could return anything as long as the appender knows what to do with it).** --- types/log4js.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/log4js.d.ts b/types/log4js.d.ts index 7ae36f5..7b3c91a 100644 --- a/types/log4js.d.ts +++ b/types/log4js.d.ts @@ -17,7 +17,7 @@ export function getLogger(category?: string): Logger; export function configure(filename: string): Log4js; export function configure(config: Configuration): Log4js; -export function addLayout(name: string, config: (a: any) => (logEvent: LoggingEvent) => string): void; +export function addLayout(name: string, config: (a: any) => (logEvent: LoggingEvent) => any): void; export function connectLogger(logger: Logger, options: { format?: Format; level?: string; nolog?: any; statusRules?: any[] }): any; // express.Handler; From 09026204369ae149590b2e3d049ea12d8769b28e Mon Sep 17 00:00:00 2001 From: Ivkaa Date: Tue, 30 Apr 2019 11:12:19 +0200 Subject: [PATCH 2/5] Add missing types for addLevels --- types/log4js.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/log4js.d.ts b/types/log4js.d.ts index 7ae36f5..9e7e143 100644 --- a/types/log4js.d.ts +++ b/types/log4js.d.ts @@ -264,6 +264,7 @@ export interface Levels { OFF: Level; levels: Level[]; getLevel(level: string): Level; + addLevels(customLevels: object): void; } export interface Configuration { From 317fca0f31f2a22727e14b9a13989ce11f7fe0e1 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Wed, 1 May 2019 08:11:42 +1000 Subject: [PATCH 3/5] chore: updated changelog for merged PR --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3b03de..4c00c78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # log4js-node changelog +## 4.1.1 +* [Add missing types for addLevels](https://github.com/log4js-node/log4js-node/pull/867) - thanks [@Ivkaa](https://github.com/Ivkaa) + ## 4.1.0 * Updated streamroller to 1.0.4, to fix a bug where the inital size of an existing file was ignored when appending From e6f9f2883050cb04fc838e42aed720cb473f43c1 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Thu, 2 May 2019 08:35:26 +1000 Subject: [PATCH 4/5] fix: failing test on node v6 --- test/tap/configuration-validation-test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/tap/configuration-validation-test.js b/test/tap/configuration-validation-test.js index 6a0a6aa..39c7789 100644 --- a/test/tap/configuration-validation-test.js +++ b/test/tap/configuration-validation-test.js @@ -297,6 +297,11 @@ test('log4js configuration validation', (batch) => { sandboxConfig.requires[ `${path.join(mainPath, '../../node_modules/nyc/bin/cheese')}` ] = testAppender('correct', result); + // in node v6, there's an extra layer of node modules for some reason, so add this one to work around it + sandboxConfig.requires[ + `${path.join(mainPath, '../../node_modules/tap/node_modules/nyc/bin/cheese')}` + ] = testAppender('correct', result); + const sandboxedLog4js = sandbox.require('../../lib/log4js', sandboxConfig); sandboxedLog4js.configure({ From 170fcbae48136cbe1d74f8f1ac1ee666e25dfacd Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 3 May 2019 08:06:54 +1000 Subject: [PATCH 5/5] chore: updated changelog for merged PR --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c00c78..cd81cf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 4.1.1 * [Add missing types for addLevels](https://github.com/log4js-node/log4js-node/pull/867) - thanks [@Ivkaa](https://github.com/Ivkaa) +* [Allow any return type for layout function](https://github.com/log4js-node/log4js-node/pull/845) - thanks [@xinbenlv](https://github.com/xinbenlv) ## 4.1.0