You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.5 KiB
57 lines
1.5 KiB
/**
|
|
* Created by rain on 2015/11/12.
|
|
*/
|
|
/**
|
|
* Created by nestn on 2015/11/10.
|
|
*/
|
|
'use strict';
|
|
|
|
const logger = require('../lib/logger');
|
|
const should = require('should');
|
|
const compose = require('koa-compose');
|
|
const co = require('co');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
const os = require('os');
|
|
|
|
describe('logger test', function () {
|
|
it('logger init', function (done) {
|
|
let config = {
|
|
level: 'debug',
|
|
filename: path.join(__dirname, 'log', 'test.txt'),
|
|
json: false,
|
|
logstash: false,
|
|
colorize: true,
|
|
maxsize: 1024 * 1024 * 5,
|
|
rotationFormat: false,
|
|
zippedArchive: true,
|
|
maxFiles: 10,
|
|
prettyPrint: true,
|
|
label: '',
|
|
timestamp: true,
|
|
eol: os.EOL,
|
|
tailable: true,
|
|
depth: null,
|
|
showLevel: true,
|
|
maxRetries: 1
|
|
};
|
|
try {
|
|
fs.unlinkSync(config.filename);
|
|
}
|
|
catch (ex) {
|
|
}
|
|
let app = {};
|
|
let gen = logger(app, config);
|
|
let ctx = {};
|
|
compose([co.wrap(gen)])(ctx).then(function () {
|
|
ctx.fs.logger.log("debug", "[TEST]", "a log msg.", function () {
|
|
let stat = fs.statSync(config.filename);
|
|
stat.isFile().should.be.true;
|
|
done();
|
|
});
|
|
}).catch(function (err) {
|
|
console.log(err);
|
|
done();
|
|
});
|
|
});
|
|
});
|