Skip to content

Conversation

@nofun97
Copy link
Contributor

@nofun97 nofun97 commented Feb 26, 2020

Standard format is now changed to

(timestamp) (level) (fields) (message)

Also removed some dead code

The reason for the change is that, previously level is put after fields and it is difficult to find the level as the number of fields varies. Putting it next to timestamps just makes it easier to find.

@nofun97 nofun97 requested a review from anzboi February 26, 2020 03:24
Copy link
Member

@anzboi anzboi left a comment

Choose a reason for hiding this comment

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

One question about the change in the formatter

message := strings.Builder{}
message.WriteString(entry.Time.Format(time.RFC3339Nano))
message.WriteByte(' ')
sections := append(make([]string, 0, 5), entry.Time.Format(time.RFC3339Nano), strings.ToUpper(entry.Level.String()))
Copy link
Member

Choose a reason for hiding this comment

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

Interesting idea, does this provide a performance improvement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's really just because I was frustrated with managing the whitespaces though I remembered I tried comparing Join and using the Builder (my test was small) and there wasn't really any difference, at least with small cases.

@anzdaddy
Copy link
Contributor

anzdaddy commented Mar 4, 2020

Please document the why in the description (and make sure it ends up in the commit message).

@nofun97
Copy link
Contributor Author

nofun97 commented Mar 4, 2020

@anzdaddy description updated

message.WriteByte('\n')
return []byte(message.String()), nil
sections = append(sections, "\n")
return []byte(strings.Join(sections, " ")), nil
Copy link
Contributor

Choose a reason for hiding this comment

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

This will incur a performance hit due to copying the final string into a byte array. Use bytes.Buffer instead. Maybe also NewBytesBuffer(make([]byte, 0, aReasonableDefaultCapacity)).

anzopensource pushed a commit that referenced this pull request May 12, 2023
* move to prod runner and fix tag action
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.

3 participants