Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('\n\n ** Logging utility tests - test setting an external logger based on bunyan **\n\n', (t) => {
console.log(' ***** logger.js - test bunyan *****'); // eslint-disable-line
const logger = bunyan.createLogger({name: 'bunyanLogger'});
hfc.setLogger(logger);
testLogger(t);
t.end();
});
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', function (worker, code, signal) {
console.log('worker ' + worker.process.pid + ' died');
});
} else {
var client = moray.createClient({
log: bunyan.createLogger({
level: 'warn',
name: 'manta1027',
stream: process.stdout,
serializers: bunyan.stdSerializers
}),
url: process.env.MORAY_URL
});
client.once('connect', function () {
function put() {
client.putObject('manta', '1027', {}, function (err) {
if (err) {
console.error(err.stack);
}
put(i);
});
}
var max = parseInt(process.env.MANTA1027_CONCURRENCY || 20, 10);
console.log('running...');
describe('bunyan-request-logger', function () {
var infoSpy;
var errorSpy;
var app = createDefaultApp({level: bunyan.FATAL});
before(function () {
infoSpy = sinon.spy(bunyan.prototype, 'info');
errorSpy = sinon.spy(bunyan.prototype, 'error');
// hide console errors while running the tests
sinon.stub(console, 'error');
});
beforeEach(function () {
infoSpy.reset();
errorSpy.reset();
});
after(function () {
infoSpy.restore();
beforeEach(async () => {
app = new Koa();
app.on('error', () => {}); // suppress errors
ringBuffer = new bunyan.RingBuffer({limit: 100});
ringLogger = bunyan.createLogger({
name: 'test',
streams: [{
type: 'raw',
stream: ringBuffer,
level: 'trace'
}]
});
});
before(function () {
infoSpy = sinon.spy(bunyan.prototype, 'info');
errorSpy = sinon.spy(bunyan.prototype, 'error');
// hide console errors while running the tests
sinon.stub(console, 'error');
});
before(function () {
infoSpy = sinon.spy(bunyan.prototype, 'info');
errorSpy = sinon.spy(bunyan.prototype, 'error');
// hide console errors while running the tests
sinon.stub(console, 'error');
});
logger.trace('Foobar');
const g: void = logger.trace('foobar');
logger.trace({ err: new Error('type') }, 'messages');
const sf = logger.trace(new Error('ASDF'));
const t = logger.trace(new Error('asdf'));
const s = logger.trace({}, false);
const b: boolean = logger.trace();
logger.trace('foo', new Error('foo'));
// $ExpectError
const v: number = Bunyan.VERSION;
Bunyan.safeCycles()('true', false);
const consoleRawStream = new Bunyan.ConsoleRawStream()
// $ExpectError
consoleRawStream.write({ level: false })
// $ExpectError
logger.log()
// $ExpectError
logger.addSTream();
logger.trace({ err: new Error('foobar') }, 'error');
Bunyan.createLogger({
name: 'foo',
const g: void = logger.trace('foobar');
logger.trace({ err: new Error('type') }, 'messages');
const sf = logger.trace(new Error('ASDF'));
const t = logger.trace(new Error('asdf'));
const s = logger.trace({}, false);
const b: boolean = logger.trace();
logger.trace('foo', new Error('foo'));
// $ExpectError
const v: number = Bunyan.VERSION;
Bunyan.safeCycles()('true', false);
const consoleRawStream = new Bunyan.ConsoleRawStream()
// $ExpectError
consoleRawStream.write({ level: false })
// $ExpectError
logger.log()
// $ExpectError
logger.addSTream();
logger.trace({ err: new Error('foobar') }, 'error');
Bunyan.createLogger({
name: 'foo',
serializers: {
foo(data) {
const child = logger.child({});
logger.trace('Foobar');
const g: void = logger.trace('foobar');
logger.trace({ err: new Error('type') }, 'messages');
const sf = logger.trace(new Error('ASDF'));
const t = logger.trace(new Error('asdf'));
const s = logger.trace({}, false);
const b: boolean = logger.trace();
logger.trace('foo', new Error('foo'));
// $ExpectError
const v: number = Bunyan.VERSION;
Bunyan.safeCycles()('true', false);
const consoleRawStream = new Bunyan.ConsoleRawStream()
// $ExpectError
consoleRawStream.write({ level: false })
// $ExpectError
logger.log()
// $ExpectError
logger.addSTream();
logger.trace({ err: new Error('foobar') }, 'error');
opts.host = option.optarg;
break;
case 'k':
opts.keyPath = option.optarg;
break;
case 'u':
opts.url = url.parse(option.optarg).href;
break;
case 'v':
// Allows us to set -vvv -> this little hackery
// just ensures that we're never < TRACE
LOG.level(Math.max(bunyan.TRACE, (LOG.level() - 10)));
if (LOG.level() <= bunyan.DEBUG)
LOG = LOG.child({src: true});
break;
default:
process.exit(1);
break;
}
}
if (!opts.url && !process.env.MANTA_URL)
usage('url is a required argument');
if (!opts.user && !process.env.MANTA_USER)
usage('account is a required argument');