Skip to content

Freakin' Timestamps On Every Freakin' Line#297

Merged
shazow merged 9 commits intomasterfrom
timestamps
Mar 17, 2019
Merged

Freakin' Timestamps On Every Freakin' Line#297
shazow merged 9 commits intomasterfrom
timestamps

Conversation

@shazow
Copy link
Copy Markdown
Owner

@shazow shazow commented Mar 6, 2019

I have mixed feelings about this. It's not great, could be improved. Not sure if I'll get a chance to improve it anytime soon though.

Definitely no timezone support, or even per-second resolution. If this opens up those cans of worms, I'm going to be sad.

  • Current method adds a goroutine per user, would be nice to have one aggregate goroutine.
  • Do we want to remove the old timestamping thing? Should it get replaced with daily timestamps?

@Osndok
Copy link
Copy Markdown
Contributor

Osndok commented Mar 8, 2019

Exciting! Can't wait! :)

host.go Outdated
user.SetHighlight(user.Name())
}

// Gross hack to override line echo in golang.org/x/crypto/ssh/terminal
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You should feel bad.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I doooo

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@Low-power is this going to break your relay?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's not quite clear, is this "dirty hack" in a code path even without the '/timestamps' feature being requested?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@Osndok Correct, we fundamentally change how we render your own messages regardless of timestamps. This makes timestamps trivial (and possibly other things in the future).

@shazow
Copy link
Copy Markdown
Owner Author

shazow commented Mar 15, 2019

image

// Timestamp formats and colorizes the timestamp.
func (theme Theme) Timestamp(t time.Time) string {
// TODO: Change this per-theme? Or config?
return theme.sys.Format(t.Format("2006-01-02 15:04:05 UTC"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't particularly like the nearly-static yyyy-mm-dd & truly-static " UTC" strings on every line, but I find the reasoning for their inclusion to be adequate.

Although, I wonder if the reasoning would still hold after the user could explicitly set a timezone, or it were guessed by the incoming IP address... as the user would 'know' the time zone, and not need reminding every line.

I don't know how expensive the time.Format function is, but calling it for every timestamp trades runtime performance for code clarity.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

GeoIP and things like that is a lot more work, so really it's a question whether you think this should be merged now or if it should be blocked until someone someday writes the code to automatically detect timezones. :)

time.Format is not expensive enough to worry, ~everything else we do is much more expensive.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You can use the TZ environment variable, if that being passed from a SSH client, like:
ssh -o SendEnv=TZ ...

@shazow shazow merged commit c02b639 into master Mar 17, 2019
@shazow shazow deleted the timestamps branch January 6, 2022 14:12
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.

4 participants