mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
feat issue #1341 (Layouts) : use split instead of regexp
This commit is contained in:
parent
ab43399200
commit
e01c3c7bbf
@ -139,8 +139,6 @@ function patternLayout(pattern, tokens) {
|
||||
const regex =
|
||||
/%(-?[0-9]+)?(\.?-?[0-9]+)?([[\]cdhmnprzxXyflosCMAF%])(\{([^}]+)\})?|([^%]+)/;
|
||||
|
||||
const mSpecifierRegex = /\s*(-?\d)(\s*,\s*(-?\d))?\w*/;
|
||||
|
||||
pattern = pattern || TTCC_CONVERSION_PATTERN;
|
||||
|
||||
function categoryName(loggingEvent, specifier) {
|
||||
@ -215,12 +213,8 @@ function patternLayout(pattern, tokens) {
|
||||
}
|
||||
|
||||
function formatMessage(loggingEvent, specifier) {
|
||||
const match = mSpecifierRegex.exec(specifier);
|
||||
|
||||
const lowerBound = match ? parseInt(match[1], 10) : 0;
|
||||
const upperBound = match && match[3] ? parseInt(match[3], 10) : undefined;
|
||||
const [lowerBound, upperBound] = specifier ? specifier.split(',') : [];
|
||||
const dataSlice = loggingEvent.data.slice(lowerBound, upperBound);
|
||||
|
||||
return util.format(...dataSlice);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user