node-bunyan | a simple and fast JSON logging module for node.js services
kandi X-RAY | node-bunyan Summary
kandi X-RAY | node-bunyan Summary
Bunyan is a simple and fast JSON logging library for node.js services:.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Creates a new Logger instance .
- Create a new log record
- creates a log event ember for log level
- Returns a trace object containing the caller information .
- Move file recursively .
- Stringify a single record
- Resolve a level
- Create a replacer function .
- Create a new object .
- Construct a new MUT instance
node-bunyan Key Features
node-bunyan Examples and Code Snippets
$ npm install browserify bunyan
var bunyan = require('bunyan');
var log = bunyan.createLogger({name: 'play', level: 'debug'});
log.trace('this one does not emit');
log.debug('hi on debug'); // console.log
log.info('hi on info'); // console.in
/*
* Example of a MuteByEnvVars Bunyan stream to mute log records matching some
* envvars. I.e. as a way to do:
* https://github.com/trentm/node-bunyan/issues/175
* https://github.com/trentm/node-bunyan/pull/176
* outside of core.
*
#!/usr/bin/env node
/**
* was a request to have
* bunyan core support logging some levels to one stream and others to another,
* *not* limited by bunyan's current support that a stream `level` implies
* "that level and higher".
*
* Let's do th
var bunyan = require('./'),
safeCycles = bunyan.safeCycles;
var util = require('util');
function SpecificLevelStream(levels, stream) {
var self = this;
this.levels = {};
levels.forEach(function (lvl) {
self.levels[bunyan.res
var colors = require('colors');
var bunyan = require('bunyan');
function MyRawStream() {}
MyRawStream.prototype.write = function (rec) {
console.log('[%s] %s: %s',
rec.time.toISOString(),
bunyan.nameFromLevel[rec.level
const bunyan = require('bunyan')
const serializers = {
valuesWithIds: vals => vals.map(v => v.value)
}
const logger = bunyan.createLogger({ name: 'root', level: 'error' })
const valuesWithIds = [{ id: 1, value: 'a' }, { id: 1, val
var bunyan = require('bunyan');
function modifiedStream(filePath) {
return {
write: log => {
log.level = bunyan.nameFromLevel[log.level];
log.time = new Date().valueOf();
log._timeStamp = new Date().toISOString(
const bunyan = require( "bunyan" ),
stream = require( "stream" );
class MyStream extends stream.Writable {
/**
* When we have a record from bunyan
*/
write( record ) {
console.log( "-----> ", record
"bunyan": "^1.8.8"
var bunyan = require('bunyan');
var log = bunyan.createLogger({name: "myapp"});
log.info("Hello!");
Community Discussions
Trending Discussions on node-bunyan
QUESTION
Sentry by defaults has integration for console.log
to make it part of breadcrumbs:
Link: Import name: Sentry.Integrations.Console
How can we make it to work for bunyan logger as well, like:
...ANSWER
Answered 2018-Nov-15 at 04:26Bunyan supports custom streams, and those streams are just function calls. See https://github.com/trentm/node-bunyan#streams
Below is an example custom stream that simply writes to the console. It would be straight forward to use this example to instead write to the Sentry module, likely calling Sentry.addBreadcrumb({})
or similar function.
Please note though that the variable record
in my example below is a JSON string, so you would likely want to parse it to get the log level, message, and other data out of it for submission to Sentry.
QUESTION
I have a module that contains one export. It's a factory function to create a bunyan logger:
...ANSWER
Answered 2018-Oct-22 at 11:13I found the solution myself. As bunyan exports a namespace, I had to change my index.ts to:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install node-bunyan
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page