Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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',
ring = this._rings[this._offset];
ring.records.length = 0;
this.requestMap.set(reqId, ring);
}
assert.ok(ring, 'no ring found');
if (record.level >= this.level) {
var i, r, ser;
for (i = 0; i < ring.records.length; i++) {
r = ring.records[i];
if (this.haveNonRawStreams) {
ser = JSON.stringify(r,
bunyan.safeCycles()) + '\n';
}
/* eslint-disable no-loop-func */
self.streams.forEach(function (s) {
s.stream.write(s.raw ? r : ser);
});
/* eslint-enable no-loop-func */
}
ring.records.length = 0;
if (this.dumpDefault) {
var defaultRing = self.requestMap.get(DEFAULT_REQ_ID);
for (i = 0; i < defaultRing.records.length; i++) {
r = defaultRing.records[i];
if (this.haveNonRawStreams) {
this.requestMap.set(req_id, ring);
}
assert.ok(ring, 'no ring found');
// write the record to the ring.
ring.write(record);
// triger dumping of all the records
if (record.level >= this.level) {
var i, r, ser;
for (i = 0; i < ring.records.length; i++) {
r = ring.records[i];
if (this.haveNonRawStreams) {
ser = JSON.stringify(r, bunyan.safeCycles()) + '\n';
}
self.streams.forEach(function forEach(s) {
s.stream.write(s.raw ? r : ser);
});
}
ring.records.length = 0;
if (this.dumpDefault) {
var defaultRing = self.requestMap.get(DEFAULT_REQ_ID);
for (i = 0; i < defaultRing.records.length; i++) {
r = defaultRing.records[i];
if (this.haveNonRawStreams) {
ser = JSON.stringify(r, bunyan.safeCycles()) + '\n';
}
write (record) {
try {
if (record.err) {
record = _.assign({}, record, { err: bunyan.stdSerializers.err(record.err) });
}
super.write(JSON.stringify(record, bunyan.safeCycles()) + '\n');
} catch (e) {
console.error(`Error in JSON.stringify()`, e, record);
}
}
}
ring.records.forEach(function (r) {
var ser = JSON.stringify(r, bunyan.safeCycles()) + '\n';
self.streams.forEach(function (s) {
s.stream.write(s.raw ? r : ser);
});
});
} else {
export function jsonFormat(obj, hasColors): string {
const msg = fillInMsgTemplate(obj.msg, obj, hasColors);
return `${JSON.stringify({ ...obj, msg }, Logger.safeCycles())}\n`;
}