erikhazzard / bragi-node Goto Github PK
View Code? Open in Web Editor NEWBragi is colorful, discrete, and sophisticated NodeJS logging framework
Home Page: http://vasir.net/blog/programming/bragi-a-javascript-logging-library
License: MIT License
Bragi is colorful, discrete, and sophisticated NodeJS logging framework
Home Page: http://vasir.net/blog/programming/bragi-a-javascript-logging-library
License: MIT License
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.
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.
// Transport specific settings
// ----------------------------------
this.showColors = options.showColors === undefined ? true : options.showColor;
showColors or showColor?
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?
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.
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;
}
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?
logger.log("debug","%s %s", undefined,true)
This produces the following output:
true %s
I would expect the out to be:
undefined true
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
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."
The following will not log the zero
$.log("splitFile:readCB:verbose", 0)
also
var temp = 0
$.log("splitFile:readCB:verbose", temp)
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.