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

2.0 Wishlist #388

Open
akshayjshah opened this issue Mar 23, 2017 · 18 comments
Open

2.0 Wishlist #388

akshayjshah opened this issue Mar 23, 2017 · 18 comments

Comments

@akshayjshah
Copy link
Contributor

akshayjshah commented Mar 23, 2017

This is a catch-all issue for our 2.0 wish list. If this list gets long and compelling enough, we'll consider cutting a new major version.

@akshayjshah
Copy link
Contributor Author

akshayjshah commented Mar 23, 2017

Copied from #387

Un-export Field internals

The original plan (see #13) with fields was to keep the implementation details completely private, and the only way to use a field would be to AddTo(Encoder).

It seems like FieldType is exported only to let the zap package expose field constructors, but I think what we should unexport all implementation details and instead:

  • Expose the same field constructors in the zapcore package
  • The zap package just wraps the underlying zapcore functions, and doesn't need access to the internals of a field.

This gives us more flexibility to change Field implementation details in future.

@akshayjshah
Copy link
Contributor Author

akshayjshah commented Apr 29, 2017

Unify the zap and zapcore packages

The intention here was to separate user-facing APIs from APIs relevant only to extension authors. Unfortunately, the division has only made things more confusing - in particular, separating the many zapcore.Field constructors from the type definition makes the GoDoc output quite daunting.

NB, we can probably fix this in Go 1.9 by moving all the code to the zap package and leaving aliases for exported identifiers in the zapcore package.

@akshayjshah
Copy link
Contributor Author

akshayjshah commented Sep 21, 2017

Configurable field order in the console encoder

Not everyone likes the order in the current console encoder. Making this configurable would be nice.

@prashantv
Copy link
Collaborator

Copied from #387

Provide String method on Field

If a user tries to print fields, the output is pretty hard to understand, e.g.,

fmt.Println(zap.Error(errors.New("test")))

results in:

{error 25 0  test}

We should probably include a String method that returns easier to understand output.

Since the current field implementation exports the internals (#387), we can't add a String method until we unexport the internals.

@tchap
Copy link

tchap commented Jan 17, 2018

Change zapcore.Core interface to split checking and adding core to the entry

I have been constantly having difficulties wrapping zapcore.Core to add what I needed.

Imagine I want to wrap a core to add filtering based on log entry. This would have to be done in Write since only there you know all the fields, which is what I needed. But checking whether to write an entry or not in Write is too late, because the wrapped core has already been added to the log entry in Check, because it not only checks, it also adds.

I encountered the same issue when I wanted to implement a core that would intercept level checking, i.e. to wrap a core to put an AtomicEnabler in front of it, which would enable me to dynamically drop the log level while not knowing the original LevelEnabler. This is also impossible AFAIK, because you have to call Check to add a core to every entry. But Check on the wrapped core always uses that core's LevelEnabler and it is not possible to replace it with my new AtomicEnabler.

zapcore.Core really sucks in this respect heavily, unless I am just unable to guess the right way how to do things...

@AshKash

This comment has been minimized.

@akshayjshah

This comment has been minimized.

@akshayjshah
Copy link
Contributor Author

Add Binary support to ArrayEncoder

zapcore.ObjectEncoder supports logging binary blobs, but zapcore.ArrayEncoder doesn't. This isn't a huge problem, but it made thriftrw/thriftrw-go#366 more complex (and less encoding-agnostic).

@akshayjshah
Copy link
Contributor Author

Support nil in Encoder interfaces

The ObjectEncoder and ArrayEncoder interfaces should support logging null values. Today, the only way to do this is via reflection, which isn't ideal for a strongly-typed API.

Copied from #630.

@awkj
Copy link

awkj commented Dec 10, 2018

change go.uber.org to github/user-go/zap
use private url instead github cause a lot of trouble, if 2.0 is breaking change , I suggest fix it.

@akshayjshah
Copy link
Contributor Author

Avoid checking the time where possible

Rather than eagerly calling time.Now, do this just before logging. This cuts the expense of debug logging significantly. See #664 for details.

Thanks to @fgrosse and @pjvds for suggesting this.

@yurishkuro
Copy link

I would like to propose Support for logging contextual metadata #654.

@jbizzle
Copy link
Contributor

jbizzle commented Nov 7, 2019

Related to #753, if we ever decide to release a breaking change, we might consider opening up the nil type with a field type like zapcore.NilType, and adding AddNil() to interfaces like zapcore.ObjectEncoder.

@StevenACoffman
Copy link

Perhaps there's a method I'm not aware of, but I would like to introspect the current log level, to turn off expensive debug calculations:

func IsDebugEnabled() bool {...}

@prashantv
Copy link
Collaborator

Perhaps there's a method I'm not aware of, but I would like to introspect the current log level, to turn off expensive debug calculations:

The underlying Core implements LevelEnabler which provides a Enabled(Level), so you can already do this in v1: logger.Core().Enabled(zap.DebugLevel).

Separately, this isn't a v2 request, but it something we could make easier in V1.

@samsondav
Copy link

Add Trace level.

#933

@xqbumu
Copy link

xqbumu commented Nov 25, 2021

Use generics with Field in go 1.18 to reduce the lines.

@abhinav
Copy link
Collaborator

abhinav commented Apr 8, 2022

Another 2.0 item:

Drop ServeHTTP from AtomicLevel

This adds a dependency on net/http, which can inflate the binary size for CLIs and any other system that cares about binary size and doesn't need HTTP support.

halfcrazy added a commit to halfcrazy/zap that referenced this issue Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests