Merge pull request #1183 from log4js-node/defensive-coding

Defensive coding
This commit is contained in:
Lam Wei Li 2022-02-02 03:19:10 +08:00 committed by GitHub
commit 00aacbc539
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 5 deletions

View File

@ -10,7 +10,7 @@ function openTheStream(filename, pattern, options) {
options
);
stream.on('error', (err) => {
console.error('log4js.dateFileAppender - Writing to file %s, error happened ', filename, err); //eslint-disable-line
console.error('log4js.dateFileAppender - Writing to file %s, error happened ', filename, err); // eslint-disable-line
});
stream.on("drain", () => {
process.emit("log4js:pause", false);

View File

@ -21,7 +21,7 @@ function openTheStream(file, fileSize, numFiles, options) {
options
);
stream.on('error', (err) => {
console.error('log4js.fileAppender - Writing to file %s, error happened ', file, err); //eslint-disable-line
console.error('log4js.fileAppender - Writing to file %s, error happened ', file, err); // eslint-disable-line
});
stream.on('drain', () => {
process.emit("log4js:pause", false);

View File

@ -24,7 +24,7 @@ const appenders = new Map();
const tryLoading = (modulePath, config) => {
debug('Loading module from ', modulePath);
try {
return require(modulePath); //eslint-disable-line
return require(modulePath); // eslint-disable-line
} catch (e) {
// if the module was found, and we still got an error, then raise it
configuration.throwExceptionIf(
@ -39,7 +39,7 @@ const tryLoading = (modulePath, config) => {
const loadAppenderModule = (type, config) => coreAppenders.get(type)
|| tryLoading(`./${type}`, config)
|| tryLoading(type, config)
|| (require.main && tryLoading(path.join(path.dirname(require.main.filename), type), config))
|| (require.main && require.main.filename && tryLoading(path.join(path.dirname(require.main.filename), type), config))
|| tryLoading(path.join(process.cwd(), type), config);
const appendersLoading = new Set();

View File

@ -3,7 +3,7 @@ function logLevelFilter(minLevelString, maxLevelString, appender, levels) {
const maxLevel = levels.getLevel(maxLevelString, levels.FATAL);
return (logEvent) => {
const eventLevel = logEvent.level;
if (eventLevel.isGreaterThanOrEqualTo(minLevel) && eventLevel.isLessThanOrEqualTo(maxLevel)) {
if (minLevel.isLessThanOrEqualTo(eventLevel) && maxLevel.isGreaterThanOrEqualTo(eventLevel)) {
appender(logEvent);
}
};