Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: added tests for Node.js 8.x #1303

Merged
merged 13 commits into from Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 16.x, 18.x]
node-version: [8.x, 10.x, 12.x, 14.x, 16.x, 18.x]
os: [ubuntu-latest, windows-latest]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

Expand Down
3 changes: 1 addition & 2 deletions .prettierignore
@@ -1,3 +1,2 @@
**/.*
coverage
.github
.nyc_output
4 changes: 2 additions & 2 deletions docs/_layouts/default.html
Expand Up @@ -87,11 +87,11 @@ <h1>{{ site.title | default: site.github.repository_name }}</h1>

{% if site.google_analytics %}
<script>
(function (i, s, o, g, r, a, m) {
(function(i, s, o, g, r, a, m) {
i["GoogleAnalyticsObject"] = r;
(i[r] =
i[r] ||
function () {
function() {
(i[r].q = i[r].q || []).push(arguments);
}),
(i[r].l = 1 * new Date());
Expand Down
2 changes: 1 addition & 1 deletion docs/connect-logger.md
Expand Up @@ -20,7 +20,7 @@ log4js.configure({
var logger = log4js.getLogger("cheese");
var app = express();
app.use(log4js.connectLogger(logger, { level: "info" }));
app.get("/", function (req, res) {
app.get("/", function(req, res) {
res.send("hello world");
});
app.listen(5000);
Expand Down
6 changes: 3 additions & 3 deletions docs/layouts.md
Expand Up @@ -161,7 +161,7 @@ log4js.configure({
type: "pattern",
pattern: "%d %p %c %x{user} %m%n",
tokens: {
user: function (logEvent) {
user: function(logEvent) {
return AuthLibrary.currentUser();
},
},
Expand Down Expand Up @@ -219,8 +219,8 @@ This example can also be found in examples/custom-layout.js.
```javascript
const log4js = require("log4js");

log4js.addLayout("json", function (config) {
return function (logEvent) {
log4js.addLayout("json", function(config) {
return function(logEvent) {
return JSON.stringify(logEvent) + config.separator;
};
});
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-layout.js
Expand Up @@ -3,7 +3,7 @@ const log4js = require('../lib/log4js');
log4js.addLayout(
'json',
(config) =>
function (logEvent) {
function(logEvent) {
return JSON.stringify(logEvent) + config.separator;
}
);
Expand Down
2 changes: 1 addition & 1 deletion examples/hipchat-appender.js
Expand Up @@ -44,7 +44,7 @@ log4js.configure({
hipchat_room: process.env.HIPCHAT_ROOM || '< Room ID or Name >',
hipchat_from: 'Mr. Semantics',
hipchat_notify: false,
hipchat_response_callback: function (err, response, body) {
hipchat_response_callback: function(err, response, body) {
if (err || response.statusCode > 300) {
throw new Error('hipchat-notifier failed');
}
Expand Down
2 changes: 1 addition & 1 deletion examples/patternLayout-tokens.js
Expand Up @@ -8,7 +8,7 @@ log4js.configure({
type: 'pattern',
pattern: '%[%r (%x{pid}) %p %c -%] %m%n',
tokens: {
pid: function () {
pid: function() {
return process.pid;
},
},
Expand Down
4 changes: 2 additions & 2 deletions lib/appenders/dateFile.js
Expand Up @@ -35,7 +35,7 @@ function appender(filename, pattern, layout, options, timezoneOffset) {

const writer = openTheStream(filename, pattern, options);

const app = function (logEvent) {
const app = function(logEvent) {
if (!writer.writable) {
return;
}
Expand All @@ -44,7 +44,7 @@ function appender(filename, pattern, layout, options, timezoneOffset) {
}
};

app.shutdown = function (complete) {
app.shutdown = function(complete) {
writer.end('', 'utf-8', complete);
};

Expand Down
8 changes: 4 additions & 4 deletions lib/appenders/file.js
Expand Up @@ -83,7 +83,7 @@ function fileAppender(

let writer = openTheStream(file, logSize, numBackups, options);

const app = function (loggingEvent) {
const app = function(loggingEvent) {
if (!writer.writable) {
return;
}
Expand All @@ -100,18 +100,18 @@ function fileAppender(
}
};

app.reopen = function () {
app.reopen = function() {
writer.end(() => {
writer = openTheStream(file, logSize, numBackups, options);
});
};

app.sighupHandler = function () {
app.sighupHandler = function() {
debug('SIGHUP handler called.');
app.reopen();
};

app.shutdown = function (complete) {
app.shutdown = function(complete) {
sighupListeners.delete(app);
if (sighupListeners.size === 0 && mainSighupListenerStarted) {
process.removeListener('SIGHUP', mainSighupHandler);
Expand Down
9 changes: 4 additions & 5 deletions lib/appenders/multiprocess.js
Expand Up @@ -78,7 +78,7 @@ function logServer(config, actualAppender, levels) {
return actualAppender(event);
}

app.shutdown = function (cb) {
app.shutdown = function(cb) {
debug('(master) master shutdown called, closing server');
server.close(cb);
};
Expand Down Expand Up @@ -108,9 +108,8 @@ function workerAppender(config) {

function createSocket() {
debug(
`(worker) worker appender creating socket to ${
config.loggerHost || 'localhost'
}:${config.loggerPort || 5000}`
`(worker) worker appender creating socket to ${config.loggerHost ||
'localhost'}:${config.loggerPort || 5000}`
);
socket = net.createConnection(
config.loggerPort || 5000,
Expand Down Expand Up @@ -142,7 +141,7 @@ function workerAppender(config) {
buffer.push(loggingEvent);
}
}
log.shutdown = function (cb) {
log.shutdown = function(cb) {
debug('(worker) worker shutdown called');
if (buffer.length && shutdownAttempts) {
debug('(worker) worker buffer has items, waiting 100ms to empty');
Expand Down
2 changes: 1 addition & 1 deletion lib/appenders/recording.js
Expand Up @@ -3,7 +3,7 @@ const debug = require('debug')('log4js:recording');
const recordedEvents = [];

function configure() {
return function (logEvent) {
return function(logEvent) {
debug(
`received logEvent, number of events now ${recordedEvents.length + 1}`
);
Expand Down
9 changes: 4 additions & 5 deletions lib/appenders/tcp.js
Expand Up @@ -23,9 +23,8 @@ function appender(config, layout) {

function createSocket() {
debug(
`appender creating socket to ${config.host || 'localhost'}:${
config.port || 5000
}`
`appender creating socket to ${config.host ||
'localhost'}:${config.port || 5000}`
);
endMsg = `${config.endMsg || '__LOG4JS__'}`;
socket = net.createConnection(
Expand Down Expand Up @@ -62,7 +61,7 @@ function appender(config, layout) {
}
}

log.shutdown = function (cb) {
log.shutdown = function(cb) {
debug('shutdown called');
if (buffer.length && shutdownAttempts) {
debug('buffer has items, waiting 100ms to empty');
Expand All @@ -80,7 +79,7 @@ function appender(config, layout) {

function configure(config, layouts) {
debug(`configure with config = ${config}`);
let layout = function (loggingEvent) {
let layout = function(loggingEvent) {
return loggingEvent.serialise();
};
if (config.layout) {
Expand Down
7 changes: 3 additions & 4 deletions lib/layouts.js
Expand Up @@ -130,8 +130,7 @@ function dummyLayout(loggingEvent) {
*/
function patternLayout(pattern, tokens) {
const TTCC_CONVERSION_PATTERN = '%r %p %c - %m%n';
const regex =
/%(-?[0-9]+)?(\.?-?[0-9]+)?([[\]cdhmnprzxXyflos%])(\{([^}]+)\})?|([^%]+)/;
const regex = /%(-?[0-9]+)?(\.?-?[0-9]+)?([[\]cdhmnprzxXyflos%])(\{([^}]+)\})?|([^%]+)/;

pattern = pattern || TTCC_CONVERSION_PATTERN;

Expand Down Expand Up @@ -272,7 +271,7 @@ function patternLayout(pattern, tokens) {

// 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 convertFileURLToPath = function(filepath) {
const urlPrefix = 'file://';
if (filepath.startsWith(urlPrefix)) {
// https://nodejs.org/api/url.html#urlfileurltopathurl
Expand Down Expand Up @@ -386,7 +385,7 @@ function patternLayout(pattern, tokens) {
return replacement;
}

return function (loggingEvent) {
return function(loggingEvent) {
let formattedString = '';
let result;
let searchString = pattern;
Expand Down
4 changes: 2 additions & 2 deletions lib/logger.js
Expand Up @@ -141,11 +141,11 @@ function addLevelMethods(target) {
);
const isLevelMethod = levelMethod[0].toUpperCase() + levelMethod.slice(1);

Logger.prototype[`is${isLevelMethod}Enabled`] = function () {
Logger.prototype[`is${isLevelMethod}Enabled`] = function() {
return this.isLevelEnabled(level);
};

Logger.prototype[levelMethod] = function (...args) {
Logger.prototype[levelMethod] = function(...args) {
this.log(level, ...args);
};
}
Expand Down