-
Notifications
You must be signed in to change notification settings - Fork 11
#31: updates logging module to allow multiple arguments and data type… #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…nd data types that are not string
lib/log.js
Outdated
const obj = { | ||
info: (...args) => { | ||
args.forEach((e) => { | ||
logger.info(JSON.stringify(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I pass in 5 arguments, I wouldn't want to log 5 times. I think its better to log 1 time as a long string.
- Helper function that maps through
args
. If the element type is Error, then returne.toString()
. Otherwise, return the element - The helper function returns the string generated from
util.format('%j', newArray)
. I useutil.format
because I thinkJSON.stringify puts too many quotes, makes it hard to see.
- Then I will just log once:
logger.info( processArgs(args) )
}) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should add some test to your logger.
lib/log.js
Outdated
|
||
const obj = { | ||
info: (...args) => { | ||
const mappedArgs = args.map((e) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this a helper function:
const processArgs = (args) => {
return args.map....
}
…to loggingModule_2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Fix tests to have 100% code coverage
- Filename only, not the full path.
log.js
should only be logging the filename.
#31: updates logging module to allow multiple arguments and data types that are not string
This update allows followings: