mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
Merge pull request #1183 from log4js-node/defensive-coding
Defensive coding
This commit is contained in:
commit
00aacbc539
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user