Comparing version 6.4.4 to 6.4.5
# log4js-node Changelog | ||
## 6.4.5 | ||
- [chore(fix): deserialise for enableCallStack features: filename, lineNumber, columnNumber, callStack](https://github.com/log4js-node/log4js-node/pull/1230) - thanks [@peteriman](https://github.com/peteriman) | ||
- [chore(fix): fileDepth for ESM](https://github.com/log4js-node/log4js-node/pull/1224) - thanks [@peteriman](https://github.com/peteriman) | ||
- [chore(refactor): replace deprecated String.prototype.substr()](https://github.com/log4js-node/log4js-node/pull/1223) - thanks [@CommanderRoot](https://github.com/CommanderRoot) | ||
- [chore(types): LogEvent types](https://github.com/log4js-node/log4js-node/pull/1231) - thanks [@peteriman](https://github.com/peteriman) | ||
- [chore(docs): updated typescript usage](https://github.com/log4js-node/log4js-node/pull/1229) - thanks [@peteriman](https://github.com/peteriman) | ||
- [chore(dep): updated dependencies](https://github.com/log4js-node/log4js-node/pull/1232) - thanks [@peteriman](https://github.com/peteriman) | ||
- chore(dep): bump date-format from 4.0.6 to 4.0.7 | ||
- chore(dep): bump streamroller from 3.0.6 to 3.0.7 | ||
- updated package-lock.json | ||
- [chore(dep): updated dependencies](https://github.com/log4js-node/log4js-node/pull/1228) - thanks [@peteriman](https://github.com/peteriman) | ||
- chore(dev): bump eslint from 8.11.0 to 8.13.0 | ||
- chore(dev): bump eslint-plugin-import from 2.25.4 to 2.26.0 | ||
- chore(dev): bump tap from 16.0.0 to 16.0.1 | ||
- chore(dev): bump typescript from 4.6.2 to 4.6.3 | ||
- updated package-lock.json | ||
- [chore(deps): bump minimist from 1.2.5 to 1.2.6](https://github.com/log4js-node/log4js-node/pull/1227) - thanks [@Dependabot](https://github.com/dependabot) | ||
## 6.4.4 | ||
@@ -80,3 +99,5 @@ | ||
## 6.4.0 | ||
## 6.4.0 - BREAKING CHANGE 💥 | ||
New default file permissions may cause external applications unable to read logs. | ||
A [manual code/configuration change](https://github.com/log4js-node/log4js-node/pull/1141#issuecomment-1076224470) is required. | ||
@@ -83,0 +104,0 @@ - [security: default file permission to be 0o600 instead of 0o644](https://github.com/log4js-node/log4js-node/pull/1141) - thanks [ranjit-git](https://www.huntr.dev/users/ranjit-git) and [@peteriman](https://github.com/peteriman) |
@@ -12,4 +12,4 @@ function maxFileSizeUnitTransform(maxLogSize) { | ||
const validUnit = Object.keys(units); | ||
const unit = maxLogSize.substr(maxLogSize.length - 1).toLocaleUpperCase(); | ||
const value = maxLogSize.substring(0, maxLogSize.length - 1).trim(); | ||
const unit = maxLogSize.slice(-1).toLocaleUpperCase(); | ||
const value = maxLogSize.slice(0, -1).trim(); | ||
@@ -16,0 +16,0 @@ if (validUnit.indexOf(unit) < 0 || !Number.isInteger(Number(value))) { |
@@ -96,3 +96,3 @@ const debug = require('debug')('log4js:fileSync'); | ||
function index(filename_) { | ||
return parseInt(filename_.substring((`${path.basename(filename)}.`).length), 10) || 0; | ||
return parseInt(filename_.slice((`${path.basename(filename)}.`).length), 10) || 0; | ||
} | ||
@@ -99,0 +99,0 @@ |
@@ -43,5 +43,5 @@ | ||
if (logMessage.indexOf(END_MSG) > -1) { | ||
event = logMessage.substring(0, logMessage.indexOf(END_MSG)); | ||
event = logMessage.slice(0, logMessage.indexOf(END_MSG)); | ||
logTheMessage(event); | ||
logMessage = logMessage.substring(event.length + END_MSG.length) || ''; | ||
logMessage = logMessage.slice(event.length + END_MSG.length) || ''; | ||
// check for more, maybe it was a big chunk | ||
@@ -48,0 +48,0 @@ chunkReceived(); |
@@ -22,3 +22,3 @@ const debug = require('debug')('log4js:categories'); | ||
if (lastDotIndex < 0) return; // category is not a child | ||
const parentCategoryName = categoryName.substring(0, lastDotIndex); | ||
const parentCategoryName = categoryName.slice(0, lastDotIndex); | ||
let parentCategory = config.categories[parentCategoryName]; | ||
@@ -185,3 +185,3 @@ | ||
debug(`configForCategory: ${category} has hierarchy, cloning from parents`); | ||
sourceCategoryConfig = { ...configForCategory(category.substring(0, category.lastIndexOf('.'))) }; | ||
sourceCategoryConfig = { ...configForCategory(category.slice(0, category.lastIndexOf('.'))) }; | ||
} else { | ||
@@ -188,0 +188,0 @@ if (!categories.has('default')) { |
@@ -5,2 +5,3 @@ const dateFormat = require('date-format'); | ||
const path = require('path'); | ||
const url = require('url'); | ||
const debug = require('debug')('log4js:layouts'); | ||
@@ -160,3 +161,3 @@ | ||
process.emitWarning( | ||
"Pattern %d{ABSOLUTE} is deprecated in favor of %d{ABSOLUTETIME}. " + | ||
"Pattern %d{ABSOLUTE} is deprecated in favor of %d{ABSOLUTETIME}. " + | ||
"Please use %d{ABSOLUTETIME} instead.", | ||
@@ -255,2 +256,31 @@ "DeprecationWarning", "log4js-node-DEP0003" | ||
let filename = loggingEvent.fileName || ''; | ||
// support for ESM as it uses url instead of path for file | ||
/* istanbul ignore next: unsure how to simulate ESM for test coverage */ | ||
const convertFileURLToPath = function(filepath) { | ||
const urlPrefix = 'file://'; | ||
if (filepath.startsWith(urlPrefix)) { | ||
// https://nodejs.org/api/url.html#urlfileurltopathurl | ||
if (typeof url.fileURLToPath === 'function') { | ||
filepath = url.fileURLToPath(filepath); | ||
} | ||
// backward-compatible for nodejs pre-10.12.0 (without url.fileURLToPath method) | ||
else { | ||
// posix: file:///hello/world/foo.txt -> /hello/world/foo.txt -> /hello/world/foo.txt | ||
// win32: file:///C:/path/foo.txt -> /C:/path/foo.txt -> \C:\path\foo.txt -> C:\path\foo.txt | ||
// win32: file://nas/foo.txt -> //nas/foo.txt -> nas\foo.txt -> \\nas\foo.txt | ||
filepath = path.normalize(filepath.replace(new RegExp(`^${urlPrefix}`), '')); | ||
if (process.platform === 'win32') { | ||
if (filepath.startsWith('\\')) { | ||
filepath = filepath.slice(1); | ||
} else { | ||
filepath = path.sep + path.sep + filepath; | ||
} | ||
} | ||
} | ||
} | ||
return filepath; | ||
}; | ||
filename = convertFileURLToPath(filename); | ||
if (specifier) { | ||
@@ -307,3 +337,3 @@ const fileDepth = parseInt(specifier, 10); | ||
if (truncation) { | ||
len = parseInt(truncation.substr(1), 10); | ||
len = parseInt(truncation.slice(1), 10); | ||
// negative truncate length means truncate from end of string | ||
@@ -320,3 +350,3 @@ return len > 0 ? toTruncate.slice(0, len) : toTruncate.slice(len); | ||
if (padding.charAt(0) === '-') { | ||
len = parseInt(padding.substr(1), 10); | ||
len = parseInt(padding.slice(1), 10); | ||
// Right pad with spaces | ||
@@ -366,3 +396,3 @@ while (toPad.length < len) { | ||
} | ||
searchString = searchString.substr(result.index + result[0].length); | ||
searchString = searchString.slice(result.index + result[0].length); | ||
} | ||
@@ -369,0 +399,0 @@ return formattedString; |
@@ -68,2 +68,9 @@ const flatted = require('flatted'); | ||
}); | ||
rehydratedEvent.location = { | ||
functionName: rehydratedEvent.functionName, | ||
fileName: rehydratedEvent.fileName, | ||
lineNumber: rehydratedEvent.lineNumber, | ||
columnNumber: rehydratedEvent.columnNumber, | ||
callStack: rehydratedEvent.callStack | ||
}; | ||
event = new LoggingEvent( | ||
@@ -73,3 +80,4 @@ rehydratedEvent.categoryName, | ||
rehydratedEvent.data, | ||
rehydratedEvent.context | ||
rehydratedEvent.context, | ||
rehydratedEvent.location | ||
); | ||
@@ -76,0 +84,0 @@ event.startTime = new Date(rehydratedEvent.startTime); |
{ | ||
"name": "log4js", | ||
"version": "6.4.4", | ||
"version": "6.4.5", | ||
"description": "Port of Log4js to work with node.", | ||
@@ -46,7 +46,7 @@ "homepage": "https://log4js-node.github.io/log4js-node/", | ||
"dependencies": { | ||
"date-format": "^4.0.6", | ||
"date-format": "^4.0.7", | ||
"debug": "^4.3.4", | ||
"flatted": "^3.2.5", | ||
"rfdc": "^1.3.0", | ||
"streamroller": "^3.0.6" | ||
"streamroller": "^3.0.7" | ||
}, | ||
@@ -58,7 +58,7 @@ "devDependencies": { | ||
"deep-freeze": "0.0.1", | ||
"eslint": "^8.11.0", | ||
"eslint": "^8.13.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-import-resolver-node": "^0.3.6", | ||
"eslint-plugin-import": "^2.25.4", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
@@ -70,4 +70,4 @@ "fs-extra": "^10.0.1", | ||
"proxyquire": "^2.1.3", | ||
"tap": "^16.0.0", | ||
"typescript": "^4.6.2", | ||
"tap": "^16.0.1", | ||
"typescript": "^4.6.3", | ||
"validate-commit-msg": "^2.14.0" | ||
@@ -74,0 +74,0 @@ }, |
@@ -102,12 +102,11 @@ log4js-node [![CodeQL](https://github.com/log4js-node/log4js-node/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/log4js-node/log4js-node/actions/workflows/codeql-analysis.yml) [![Node.js CI](https://github.com/log4js-node/log4js-node/actions/workflows/node.js.yml/badge.svg)](https://github.com/log4js-node/log4js-node/actions/workflows/node.js.yml) | ||
```ts | ||
import { configure, getLogger } from "log4js"; | ||
configure("./filename"); | ||
const logger = getLogger(); | ||
logger.level = "debug"; | ||
logger.debug("Some debug messages"); | ||
configure({ | ||
import log4js from "log4js"; | ||
log4js.configure({ | ||
appenders: { cheese: { type: "file", filename: "cheese.log" } }, | ||
categories: { default: { appenders: ["cheese"], level: "error" } } | ||
}); | ||
const logger = log4js.getLogger(); | ||
logger.level = "debug"; | ||
logger.debug("Some debug messages"); | ||
``` | ||
@@ -114,0 +113,0 @@ |
@@ -69,2 +69,7 @@ // Type definitions for log4js | ||
}; | ||
functionName?: string; | ||
fileName?: string; | ||
lineNumber?: number; | ||
columnNumber?: number; | ||
callStack?: string; | ||
} | ||
@@ -71,0 +76,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
135195
3010
122
Updateddate-format@^4.0.7
Updatedstreamroller@^3.0.7