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

Why do you need levelWriterAdapter? #2

Closed
kemics opened this issue May 17, 2017 · 1 comment
Closed

Why do you need levelWriterAdapter? #2

kemics opened this issue May 17, 2017 · 1 comment

Comments

@kemics
Copy link

kemics commented May 17, 2017

Hello,

I wanted to ask, why do you need levelWriterAdapter, that implements LevelWriter, if it WriteLevel just calls the Write io.Writer method with no level usage?

And the second question, don't you think, that in MultiLevelWriter() function it is better to create lwriters with initial length == len(writers)), just like this:
lwriters := make([]LevelWriter, len(writers)) and then add elements by index?

Thank you for your package, it is really nice

@rs
Copy link
Owner

rs commented May 20, 2017

New want an io.Writer but if the writer does also implement LevelWriter I use it. The levelWriterAdapter is used here to unify all writers and save a type assertion/condition on each write.

The make([]T, 0, len) with append is equivalent to make([]T, len) with index performance-wise and I prefer the style of the former.

@rs rs closed this as completed Jun 23, 2017
rs pushed a commit that referenced this issue Aug 16, 2021
* Create dependabot.yml
* Update test.yml
* Bump golang.org/x/tools from 0.1.3 to 0.1.5 (#1)
* Bump github.com/rs/xid from 1.2.1 to 1.3.0 (#2)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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

No branches or pull requests

2 participants