Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Commit 8c66648

Browse files
committed
fix documentation/configuration layout
1 parent 2c44a85 commit 8c66648

File tree

10 files changed

+23
-23
lines changed

10 files changed

+23
-23
lines changed

docs/_includes/sections/pattern-layout.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ <h2>Specifying a Layout</h2>
1010

1111
{% highlight typescript %}
1212
configure({
13-
patternLayout: '%d [%p] %c - %m', // default
13+
layout: '%d [%p] %c - %m', // default
1414
appenders: [{
1515
appender: 'Console',
16-
patternLayout: '%d{ISO8601} [%p] - %m %exception' // appender
16+
layout: '%d{ISO8601} [%p] - %m %exception' // appender
1717
}],
1818
loggers: [{
1919
tag: 'App',
20-
patternLayout: '%c.%method (%line:%column) %m %ex' // logger
20+
layout: '%c.%method (%line:%column) %m %ex' // logger
2121
}]
2222
});
2323
{% endhighlight %}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@log4js2/core",
3-
"version": "2.0.0-beta.4",
3+
"version": "2.0.0-beta.5",
44
"scripts": {
55
"build": "npm run lint && tsc",
66
"lint": "tslint -p tsconfig.json -c tslint.json",

src/__mocks__/configuration.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ configure({
1313
appenders: [{
1414
appender: CustomAppender
1515
}],
16-
patternLayout: '%c - %m',
16+
layout: '%c - %m',
1717
loggers: [{
1818
level: LogLevel.INFO
1919
}, {
@@ -22,19 +22,19 @@ configure({
2222
}, {
2323
tag: TEST_LOGGER_2,
2424
level: LogLevel.INFO,
25-
patternLayout: '%c [%p] %m'
25+
layout: '%c [%p] %m'
2626
}, {
2727
tag: ERROR_LOGGER,
2828
level: LogLevel.ERROR,
29-
patternLayout: '%ex'
29+
layout: '%ex'
3030
}, {
3131
tag: MAP_LOGGER,
3232
level: LogLevel.INFO,
33-
patternLayout: '%K'
33+
layout: '%K'
3434
}, {
3535
tag: MARKER_LOGGER,
3636
level: LogLevel.INFO,
37-
patternLayout: '%marker'
37+
layout: '%marker'
3838
}, {
3939
tag: CUSTOM_LOGGER,
4040
level: LogLevel.TRACE

src/__tests__/appender.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { configure, getLogger } from '../log4js';
55

66
configure({
77
level: LogLevel.DEBUG,
8-
patternLayout: '%m'
8+
layout: '%m'
99
});
1010

1111
describe('Logger', () => {

src/__tests__/logging.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('Message', () => {
66

77
configure({
88
level: LogLevel.INFO,
9-
patternLayout: '%c - %m'
9+
layout: '%c - %m'
1010
});
1111

1212
// create a log stack we can throw logs into

src/config/appender.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ export default interface IAppenderConfiguration<C = any, T extends LogAppender<C
99
config?: any;
1010
filters?: Array<IFilterConfiguration<any, LogFilter<any>>>;
1111
level?: LogLevel | number;
12-
patternLayout?: string;
12+
layout?: string;
1313

1414
}

src/config/configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default interface IConfiguration {
1010
level?: LogLevel;
1111
appenders?: AppenderConfigurationItem[] | string[];
1212
loggers?: ILoggerConfiguration[];
13-
patternLayout?: string;
13+
layout?: string;
1414
virtualConsole?: boolean;
1515

1616
}

src/config/logger.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default interface ILoggerConfiguration {
44

55
appenders?: string[];
66
level?: LogLevel | number;
7-
patternLayout?: string;
7+
layout?: string;
88
tag?: string;
99

1010
}

src/log4js.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const _DEFAULT_CONFIG = ((): IConfiguration => ({
3232
loggers: [{
3333
level: LogLevel.ERROR
3434
}],
35-
patternLayout: '%d [%p] %c - %m'
35+
layout: '%d [%p] %c - %m'
3636
}))();
3737

3838
/** @type {?IConfiguration} */
@@ -55,7 +55,7 @@ const _getAppendersForLogger = (logConfig: ILoggerConfiguration) => {
5555
getLoggerAppenderInstances(logConfig.appenders).forEach((appenderWrapper) => {
5656

5757
appenderWrapper.appender.setLogLevel(logConfig.level);
58-
appenderWrapper.appender.setLayout(logConfig.patternLayout);
58+
appenderWrapper.appender.setLayout(logConfig.layout);
5959

6060
appenderList.push(appenderWrapper);
6161

@@ -86,11 +86,11 @@ const _configureLoggers = (config: IConfiguration): IConfiguration => {
8686

8787
hasMain = hasMain || logger.tag === MAIN_LOGGER;
8888

89-
if (!logger.patternLayout || typeof logger.patternLayout !== 'string') {
90-
logger.patternLayout = config.patternLayout;
89+
if (!logger.layout || typeof logger.layout !== 'string') {
90+
logger.layout = config.layout;
9191
}
9292

93-
logger.patternLayout = logger.patternLayout || _DEFAULT_PATTERN_LAYOUT;
93+
logger.layout = logger.layout || _DEFAULT_PATTERN_LAYOUT;
9494
logger.level = logger.level || config.level || LogLevel.ERROR;
9595

9696
addLogger(logger.tag, new Logger(logger.tag, _getAppendersForLogger(logger)));
@@ -105,7 +105,7 @@ const _configureLoggers = (config: IConfiguration): IConfiguration => {
105105
const mainLoggerConfig: ILoggerConfiguration = {
106106
tag: MAIN_LOGGER,
107107
level: config.level || LogLevel.ERROR,
108-
patternLayout: config.patternLayout || _DEFAULT_PATTERN_LAYOUT,
108+
layout: config.layout || _DEFAULT_PATTERN_LAYOUT,
109109
};
110110

111111
loggers.push(mainLoggerConfig);
@@ -200,8 +200,8 @@ const _configureAppenders = (config: IConfiguration): IConfiguration => {
200200
export function configure(config: IConfiguration) {
201201

202202
// set the default layout
203-
if (!config.patternLayout) {
204-
config.patternLayout = _DEFAULT_PATTERN_LAYOUT;
203+
if (!config.layout) {
204+
config.layout = _DEFAULT_PATTERN_LAYOUT;
205205
}
206206

207207
// configure the appenders

src/logger/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const getLogger = <T>(context: string, config: ILoggerConfiguration): Log
3737
.map((appenderWrapper) => {
3838

3939
appenderWrapper.appender.setLogLevel(config.level);
40-
appenderWrapper.appender.setLayout(config.patternLayout);
40+
appenderWrapper.appender.setLayout(config.layout);
4141

4242
return appenderWrapper;
4343

0 commit comments

Comments
 (0)