adding timestamp logging to be configurable (turned on by default)#202
adding timestamp logging to be configurable (turned on by default)#202roblourens merged 3 commits intomicrosoft:masterfrom
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.
This looks like "9/28/2018 11:20:28 AM.992" right?
There was a problem hiding this comment.
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.
Also is the date really helpful on every line? Seems like just noise.
adapter/src/logger.ts
Outdated
| _logFilePath : | ||
| (_logFilePath && this._logFilePathFromInit); | ||
|
|
||
| if (typeof prependTimestamp === 'boolean') { |
There was a problem hiding this comment.
Use a default parameter prependTimestamp = true
There was a problem hiding this comment.
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.
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; |
|
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.
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