mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
Merge branch 'jdell64-log4js-update-#706'
This commit is contained in:
commit
7d82f8271e
1386
package-lock.json
generated
1386
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -58,7 +58,7 @@
|
||||
"husky": "^0.14.3",
|
||||
"nyc": "^11.7.3",
|
||||
"sandboxed-module": "^2.0.3",
|
||||
"tap": "^10.7.3",
|
||||
"tap": "^11.1.5",
|
||||
"validate-commit-msg": "^2.14.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
|
||||
@ -2,8 +2,40 @@
|
||||
|
||||
const test = require('tap').test;
|
||||
const sandbox = require('sandboxed-module');
|
||||
const consoleAppender = require('../../lib/appenders/console');
|
||||
|
||||
test('log4js console appender', (batch) => {
|
||||
batch.test('should export a configure function', (t) => {
|
||||
t.type(consoleAppender.configure, 'function');
|
||||
t.end();
|
||||
});
|
||||
|
||||
batch.test('should use default layout if none specified', (t) => {
|
||||
const messages = [];
|
||||
const fakeConsole = {
|
||||
log: function (msg) {
|
||||
messages.push(msg);
|
||||
}
|
||||
};
|
||||
const log4js = sandbox.require(
|
||||
'../../lib/log4js',
|
||||
{
|
||||
globals: {
|
||||
console: fakeConsole
|
||||
}
|
||||
}
|
||||
);
|
||||
log4js.configure({
|
||||
appenders: { console: { type: 'console' } },
|
||||
categories: { default: { appenders: ['console'], level: 'DEBUG' } }
|
||||
});
|
||||
|
||||
log4js.getLogger().info('blah');
|
||||
|
||||
t.match(messages[0], /.*default.*blah/);
|
||||
t.end();
|
||||
});
|
||||
|
||||
batch.test('should output to console', (t) => {
|
||||
const messages = [];
|
||||
const fakeConsole = {
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
const test = require('tap').test;
|
||||
const sandbox = require('sandboxed-module');
|
||||
const hipchatAppender = require('../../lib/appenders/hipchat');
|
||||
|
||||
function setupLogging(category, options) {
|
||||
const lastRequest = {};
|
||||
@ -70,6 +71,11 @@ function setupLogging(category, options) {
|
||||
}
|
||||
|
||||
test('HipChat appender', (batch) => {
|
||||
batch.test('should export a configure function', (t) => {
|
||||
t.type(hipchatAppender.configure, 'function');
|
||||
t.end();
|
||||
});
|
||||
|
||||
batch.test('when logging to HipChat v2 API', (t) => {
|
||||
const customCallback = function () {
|
||||
return 'works';
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
const test = require('tap').test;
|
||||
const sandbox = require('sandboxed-module');
|
||||
const appender = require('../../lib/appenders/logFaces-HTTP');
|
||||
|
||||
function setupLogging(category, options) {
|
||||
const fakeAxios = {
|
||||
@ -49,6 +50,11 @@ function setupLogging(category, options) {
|
||||
}
|
||||
|
||||
test('logFaces appender', (batch) => {
|
||||
batch.test('should export a configure function', (t) => {
|
||||
t.type(appender.configure, 'function');
|
||||
t.end();
|
||||
});
|
||||
|
||||
batch.test('when using HTTP receivers', (t) => {
|
||||
const setup = setupLogging('myCategory', {
|
||||
application: 'LFS-HTTP',
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
const test = require('tap').test;
|
||||
const sandbox = require('sandboxed-module');
|
||||
const appender = require('../../lib/appenders/logFaces-UDP');
|
||||
|
||||
function setupLogging(category, options) {
|
||||
const fakeDgram = {
|
||||
@ -52,6 +53,11 @@ function setupLogging(category, options) {
|
||||
}
|
||||
|
||||
test('logFaces appender', (batch) => {
|
||||
batch.test('should export a configure function', (t) => {
|
||||
t.type(appender.configure, 'function');
|
||||
t.end();
|
||||
});
|
||||
|
||||
batch.test('when using UDP receivers', (t) => {
|
||||
const setup = setupLogging('udpCategory', {
|
||||
application: 'LFS-UDP',
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
const test = require('tap').test;
|
||||
const sandbox = require('sandboxed-module');
|
||||
const appender = require('../../lib/appenders/logstashHTTP');
|
||||
|
||||
function setupLogging(category, options) {
|
||||
const fakeAxios = {
|
||||
@ -49,6 +50,11 @@ function setupLogging(category, options) {
|
||||
}
|
||||
|
||||
test('logstashappender', (batch) => {
|
||||
batch.test('should export a configure function', (t) => {
|
||||
t.type(appender.configure, 'function');
|
||||
t.end();
|
||||
});
|
||||
|
||||
batch.test('when using HTTP receivers', (t) => {
|
||||
const setup = setupLogging('myCategory', {
|
||||
application: 'logstash-sample',
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
const test = require('tap').test;
|
||||
const sandbox = require('sandboxed-module');
|
||||
const appender = require('../../lib/appenders/logstashUDP');
|
||||
|
||||
function setupLogging(category, options) {
|
||||
const udpSent = {};
|
||||
@ -49,6 +50,11 @@ function setupLogging(category, options) {
|
||||
}
|
||||
|
||||
test('logstashUDP appender', (batch) => {
|
||||
batch.test('should export a configure function', (t) => {
|
||||
t.type(appender.configure, 'function');
|
||||
t.end();
|
||||
});
|
||||
|
||||
batch.test('a UDP packet should be sent', (t) => {
|
||||
const setup = setupLogging('myCategory', {
|
||||
host: '127.0.0.1',
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
const test = require('tap').test;
|
||||
const sandbox = require('sandboxed-module');
|
||||
const appender = require('../../lib/appenders/rabbitmq');
|
||||
|
||||
function setupLogging(category, options) {
|
||||
const fakeRabbitmq = {
|
||||
@ -51,6 +52,11 @@ function setupLogging(category, options) {
|
||||
}
|
||||
|
||||
test('log4js rabbitmqAppender', (batch) => {
|
||||
batch.test('should export a configure function', (t) => {
|
||||
t.type(appender.configure, 'function');
|
||||
t.end();
|
||||
});
|
||||
|
||||
batch.test('rabbitmq setup', (t) => {
|
||||
const result = setupLogging('rabbitmq setup', {
|
||||
host: '123.123.123.123',
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
const test = require('tap').test;
|
||||
// const log4js = require('../../lib/log4js');
|
||||
const sandbox = require('sandboxed-module');
|
||||
const appender = require('../../lib/appenders/redis');
|
||||
|
||||
function setupLogging(category, options) {
|
||||
const fakeRedis = {
|
||||
@ -56,6 +56,11 @@ function setupLogging(category, options) {
|
||||
}
|
||||
|
||||
test('log4js redisAppender', (batch) => {
|
||||
batch.test('should export a configure function', (t) => {
|
||||
t.type(appender.configure, 'function');
|
||||
t.end();
|
||||
});
|
||||
|
||||
batch.test('redis setup', (t) => {
|
||||
const result = setupLogging('redis setup', {
|
||||
host: '123.123.123.123',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user