-
Notifications
You must be signed in to change notification settings - Fork 80
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
adding timestamp logging to be configurable (turned on by default) #202
Conversation
adapter/src/logger.ts
Outdated
private _formatTimestamp(): string { | ||
let d = new Date(); | ||
let millisecondString = String("000" + d.getMilliseconds()).slice(-3); | ||
return d.toLocaleDateString() + ' ' + d.toLocaleTimeString() + '.' + millisecondString; |
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.
This looks like "9/28/2018 11:20:28 AM.992"
right?
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.
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.
It depends on some detail of your computer's locale, maybe you have it set to use a 24 hour time format?
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.
Also is the date really helpful on every line? Seems like just noise.
adapter/src/logger.ts
Outdated
const logFilePath = typeof _logFilePath === 'string' ? | ||
_logFilePath : | ||
(_logFilePath && this._logFilePathFromInit); | ||
|
||
if (typeof prependTimestamp === 'boolean') { |
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.
Use a default parameter prependTimestamp = true
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 did it this way (initializing to true in the else block) because of the reason below. Should I leave the timestamps in the beginning portion by default then?
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.
Using a default parameter would be equivalent to what you already have here, it won't affect what's happening in initialization.
adapter/src/logger.ts
Outdated
log(msg: string, level = LogLevel.Log): void { | ||
if (this._prependTimestamp) { | ||
msg = this._formatTimestamp() + "::" + msg; |
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.
Maybe a space after ::
?
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.
Will do
Make sure you set your git email address so your commits are properly attributed to your github account! |
…d date to only be logged at the top, and using default parameter when passing in boolean for prepending timestamps
adapter/src/logger.ts
Outdated
let d = new Date(); | ||
let millisecondString = String("000" + d.getMilliseconds()).slice(-3); | ||
return d.toLocaleDateString() + ' ' + d.toLocaleTimeString() + '.' + millisecondString; | ||
return d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + '.' + millisecondString; |
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.
Format the other fields like you formatted milliseconds?
This is to add allow timestamps in the logging, which can be turned off in the launch config