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

Merged
merged 3 commits into from Oct 1, 2018

Conversation

Projects
None yet
2 participants
@Shenniey
Contributor

Shenniey commented Sep 28, 2018

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;

This comment has been minimized.

@roblourens

roblourens Sep 28, 2018

Member

This looks like "9/28/2018 11:20:28 AM.992" right?

This comment has been minimized.

@Shenniey

Shenniey Sep 28, 2018

Contributor

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.

This comment has been minimized.

@roblourens

roblourens Sep 28, 2018

Member

It depends on some detail of your computer's locale, maybe you have it set to use a 24 hour time format?

This comment has been minimized.

@roblourens

roblourens Sep 28, 2018

Member

Also is the date really helpful on every line? Seems like just noise.

const logFilePath = typeof _logFilePath === 'string' ?
_logFilePath :
(_logFilePath && this._logFilePathFromInit);
if (typeof prependTimestamp === 'boolean') {

This comment has been minimized.

@roblourens

roblourens Sep 28, 2018

Member

Use a default parameter prependTimestamp = true

This comment has been minimized.

@Shenniey

Shenniey Sep 28, 2018

Contributor

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?

This comment has been minimized.

@roblourens

roblourens Sep 28, 2018

Member

Using a default parameter would be equivalent to what you already have here, it won't affect what's happening in initialization.

Show resolved Hide resolved adapter/src/logger.ts
log(msg: string, level = LogLevel.Log): void {
if (this._prependTimestamp) {
msg = this._formatTimestamp() + "::" + msg;

This comment has been minimized.

@roblourens

roblourens Sep 28, 2018

Member

Maybe a space after ::?

This comment has been minimized.

@Shenniey

Shenniey Sep 28, 2018

Contributor

Will do

@roblourens

This comment has been minimized.

Member

roblourens commented Sep 28, 2018

Make sure you set your git email address so your commits are properly attributed to your github account!

Shennie Yao
added space after double colon, properly formmated milliseconds, move…
…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;

This comment has been minimized.

@roblourens

roblourens Sep 29, 2018

Member

Format the other fields like you formatted milliseconds?

Shennie Yao

@roblourens roblourens merged commit bd24ef8 into Microsoft:master Oct 1, 2018

1 check passed

license/cla All CLA requirements met.
Details

@Shenniey Shenniey deleted the Shenniey:add_timestampDefault branch Oct 9, 2018

@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