How to use the bunyan.safeCycles function in bunyan

To help you get started, we’ve selected a few bunyan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / bunyan_v1.x.x / test_bunyan_v1.x.x.js View on Github external
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',
github restify / clients / lib / helpers / bunyan.js View on Github external
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) {
github restify / node-restify / lib / bunyan_helper.js View on Github external
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';
                }
github jsdelivr / data.jsdelivr.com / src / lib / logger / index.js View on Github external
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);
		}
	}
}
github science / openthermo / server / node_modules / restify / lib / bunyan_helper.js View on Github external
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 {
github verdaccio / verdaccio / src / lib / logger / format / json.ts View on Github external
export function jsonFormat(obj, hasColors): string {
    const msg = fillInMsgTemplate(obj.msg, obj, hasColors);

    return `${JSON.stringify({ ...obj, msg }, Logger.safeCycles())}\n`;
}