Skip to content

Optimize - #14

Closed
localhots wants to merge 31 commits into
mainfrom
optimize
Closed

Optimize#14
localhots wants to merge 31 commits into
mainfrom
optimize

Conversation

@localhots

Copy link
Copy Markdown
Owner

Bunch of optimizations that make the logger ~20% faster on average workloads.

Fun fact: log.F can only take 8 fields before it allocates memory.

localhots added 30 commits April 8, 2025 02:50
* WIP

* Un-inline utf8.DecodeRuneInString

* Base64 encoding for byte slices

* Fuzzing

* Looking good

* Refactor string escape functions

* Simplify writing base64

* Upd comment

* Last funny stuff

* Runby refactorings
Main goal of this change is to setup CI: testing and linting. 

- Added test and lint actions
- Upgraded `golangci-lint` to version 2
- Made a demo command that replaced demo tests
- Added code comments and otherwise pleased the linter
Displays the message in bold font.
Since JSON logger was introduced configuration no longer applies to both
loggers equally with some options being unique to one or another logger.
This change moves encoder-specific options to encoders themselves.
Allows for easier separation of concerns between console and JSON
encoders.
Also changed default JSON field names.
- Consoler encoder prints levels in short uppercase format: `INFO`,
`ERRO`
- JSON encoder does it in full lowercase format: `info`, `error`
- Fixed time key in JSON encoder
- `WithContext` is renamed to `ContextWithFields`
- `FromContext` is renamed to `FieldsFromContext`

New function names indicate their behavior in a clear and unambiguous
way.
Buffers that grow over 10x the initial capacity are no longer returned
into the pool and instead left to be garbage collected.
When context has fields but a call to logger doesn't, context fields are
not displayed.
Replace 3 conditions with one lookup
@localhots localhots closed this Mar 23, 2026
@localhots
localhots deleted the optimize branch March 23, 2026 00:39
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.

1 participant