Giter Site home page Giter Site logo

erikhazzard / bragi-node Goto Github PK

View Code? Open in Web Editor NEW
162.0 162.0 4.0 203 KB

Bragi is colorful, discrete, and sophisticated NodeJS logging framework

Home Page: http://vasir.net/blog/programming/bragi-a-javascript-logging-library

License: MIT License

JavaScript 100.00%

bragi-node's People

Contributors

erikhazzard avatar necccc avatar popwarsweet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bragi-node's Issues

Logger not working in strict mode

Tried using logger. Everything seems fine as long as not running in strict mode. By adding "use strict"; to a file using bragi when logging you get "TypeError: Illegal access to a strict mode caller function."

groupsEnabled overrides groupsDisabled

ex. log

bragi.log("test:func:debug", "some text")

$.options.groupsEnabled = [/:test/]
$.options.groupsDisabled = [/:debug/]

This will still show the above log

I would expect it to only show logs where the groupsEnabled and groupsDisabled do not conflict. Also this does not match the behavior of when groupsEnabled is set to true.

Mimic console.log functionality allowing multiple args to be logged with spaces

I just switched to using bragi and I had a bunch of log in the format
console.log(arg1,arg2,arg3)

this outputs
arg1 arg2 arg3

But doing this
logger.log("debug",arg1,arg2,arg3)

will only print 'arg1'

Bragi does not allow this instead it only allows formatters. For example to reproduce the above behavior I have to do this:
logger.log("debug","%s %s %s",arg1,arg2,arg3)

This requires a log of refactoring. Maybe if there are no formatters in the log use this as the default or add an option to allow this or an option to turn off formatters and use this method as the default.

Include stack trace in file transport?

Hello, i'm trying to get the stack traces to be included in the file transport. Which options must I set?

I've set storeStackTrace and showStackTrace to true on both the actual logger object and in the transport options.

log with only a filter give undefined as a message

for instance in the below log you can see I just have a filter defined, there is no actual log message given. Bragi will give undefined as the log message. This always fools me into thinking I found some undefined variable in my code and I go searching for it. Only to find I did not add a log message. I think instead of undefined an empty string should be given so as to not be confusing.

bragi.log("startRoute:createMultipartUploadCB:verbose")

shows:
[ startRoute:createMultipartUploadCB:verbose ] undefined

Setting groupsEnabled/groupsDisabled with array

logger.transports.add(new logger.transportClasses.File({
  groupsEnabled: ['error', 'info'],
  groupsDisabled: [],
  filename: 'logs/test.log'
}));
console.log(logger.transports.get('File').property('groupsEnabled'));
console.log(logger.transports.get('File').property('groupsDisabled'));

Results in:

[ [ 'error', 'info' ] ]
[ [] ]

It seems like the groups arguments are being pushed into an array, which doesn't make much sense. Am I doing something wrong?

Unwanted stack traces

Main file:

var logger = require('bragi');

logger.transports.get('Console').property({
    showStackTrace: false,
    showMeta: false,
    batchEnabled: true
});

logger.log('info', 'ahhhhhhhhhh');
logger.log('info', 'ahhhhhhhhhh');
logger.log('info', 'ahhhhhhhhhh');

Output:

karlm@lnxkarlm:~/dev/node/project((HEAD отделён на 1c0fa11))$ NODE_PATH=\"$(pwd)\" node -r babel-register -r babel-polyfill src/test_log.js 
/home/karlm/dev/node/project/node_modules/bragi/lib/bragi.js 366
/home/karlm/dev/node/project/src/test_log.js 11
module.js 571
/home/karlm/dev/node/project/node_modules/babel-register/lib/node.js 144
/home/karlm/dev/node/project/node_modules/bragi/lib/bragi.js 366
/home/karlm/dev/node/project/src/test_log.js 12
module.js 571
/home/karlm/dev/node/project/node_modules/babel-register/lib/node.js 144
/home/karlm/dev/node/project/node_modules/bragi/lib/bragi.js 366
/home/karlm/dev/node/project/src/test_log.js 13
module.js 571
/home/karlm/dev/node/project/node_modules/babel-register/lib/node.js 144
[  info  ] 	ahhhhhhhhhh
[  info  ] 	ahhhhhhhhhh
[  info  ] 	ahhhhhhhhhh

I seem to be getting unwanted stack traces? Any idea?

License

Hi,

Can you add the license more explicitly?
I saw it in package.json, however add it in the README or a file in the project root folder would be nicer.

Thanks to release it.

Remove default error and warn levels

It's not a good idea to have this by default.

Example: If I wish to use the following filter: ".*:myLevel" only. I will receive those logs AND every error and warn log. I wish to specifically filter these messages, but I can't. Other logs such as error:myOtherLevel is polluting now my feed.

This specific piece of code should be removed in the bragi/lib/canLog.js file:

    // set error and warn to be always on unless explictly disabled
    if(group.indexOf('error') === 0 || group.indexOf('warn') === 0){
        canLogIt = true;
    }

logging zero produces no output

The following will not log the zero

$.log("splitFile:readCB:verbose", 0)

also

var temp = 0
$.log("splitFile:readCB:verbose", temp)

Testing File transport in mocha does not work

I've looked at your tests for bragi and they do not cover everything. So I tried to cover for example if a log file is actually made when a File transport is added. I checked to see if it worked and apparently it does not. Check below:

test/log.js

'use strict';

import fs from 'fs';
import logger from 'bragi';

// Logging to file.
logger.transports.add(new logger.transportClasses.File({
  filename: 'test.log'
}));

describe('Log', () => {
  it('logger creates a log file when a log is logged', () => {
    logger.log('error', 'test log');
  });
});

test/mocha.opts:

--recursive
--compilers js:babel-core/register
--require babel-polyfill

run via npm test, in the package.json:

"test": "NODE_ENV=test NODE_PATH=\"$(pwd)\" mocha",

As you can see, it outputs via the Console transport:

  Log
[ ✘   error  ] 	test log
  2016-12-09T10:58:26.283Z	 /home/karlm/dev/node/proj/test/log.js:20:21
    ✓ logger creates a log file when a log is logged


  1 passing (26ms)

It however does not create the file test.log.

Variable typo in Console.js

// Transport specific settings
    // ----------------------------------
    this.showColors = options.showColors === undefined ? true : options.showColor;

showColors or showColor?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.