Skip to content

adding timestamp logging to be configurable (turned on by default)#202

Merged
roblourens merged 3 commits intomicrosoft:masterfrom
Shenniey:add_timestampDefault
Oct 1, 2018
Merged

adding timestamp logging to be configurable (turned on by default)#202
roblourens merged 3 commits intomicrosoft:masterfrom
Shenniey:add_timestampDefault

Conversation

@Shenniey
Copy link
Contributor

This is to add allow timestamps in the logging, which can be turned off in the launch config

@roblourens roblourens self-assigned this Sep 28, 2018
private _formatTimestamp(): string {
let d = new Date();
let millisecondString = String("000" + d.getMilliseconds()).slice(-3);
return d.toLocaleDateString() + ' ' + d.toLocaleTimeString() + '.' + millisecondString;
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that's interesting. I'm not sure why, but when I ran it in the logs, it looks like this 2018-9-28 11:30:05.450.
img

And those were the methods used in the original formatting of the date/time. Sorry, I should have checked. I will change it.

Copy link
Member

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?

Copy link
Member

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.

_logFilePath :
(_logFilePath && this._logFilePathFromInit);

if (typeof prependTimestamp === 'boolean') {
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

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.


log(msg: string, level = LogLevel.Log): void {
if (this._prependTimestamp) {
msg = this._formatTimestamp() + "::" + msg;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a space after ::?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

@roblourens
Copy link
Member

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
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;
Copy link
Member

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?

@roblourens roblourens merged commit bd24ef8 into microsoft:master Oct 1, 2018
@Shenniey Shenniey deleted the add_timestampDefault branch October 9, 2018 22:06
@roblourens roblourens added this to the October 2018 milestone Nov 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants