Skip to content
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

changed position of level to be after timestamp #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nofun97
Copy link
Member

@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
Member 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
Member

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
Member 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
Member

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.

None yet

3 participants