Documentation
¶
Overview ¶
Package logging sets up and configures standard logging.
Index ¶
- func Default() *zap.SugaredLogger
- func FromContext(ctx context.Context) *zap.SugaredLogger
- func GRPCStreamingInterceptor(inLogger *zap.SugaredLogger, projectID string) grpc.StreamClientInterceptor
- func GRPCUnaryInterceptor(inLogger *zap.SugaredLogger, projectID string) grpc.UnaryServerInterceptor
- func HTTPInterceptor(inLogger *zap.SugaredLogger, projectID string) func(http.Handler) http.Handler
- func NewFromEnv(envPrefix string) *zap.SugaredLogger
- func TestLogger(tb zaptest.TestingT, opts ...zaptest.LoggerOption) *zap.SugaredLogger
- func WithLogger(ctx context.Context, logger *zap.SugaredLogger) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Default ¶
func Default() *zap.SugaredLogger
Default creates a default logger. To overwrite log level and mode, set LOG_LEVEL and LOG_MODE.
func FromContext ¶
func FromContext(ctx context.Context) *zap.SugaredLogger
FromContext returns the logger stored in the context. If no such logger exists, a default logger is returned.
func GRPCStreamingInterceptor ¶ added in v0.1.2
func GRPCStreamingInterceptor(inLogger *zap.SugaredLogger, projectID string) grpc.StreamClientInterceptor
GRPCStreamingInterceptor returns client-side a gRPC streaming interceptor that populates a logger with trace data in the context.
func GRPCUnaryInterceptor ¶ added in v0.1.2
func GRPCUnaryInterceptor(inLogger *zap.SugaredLogger, projectID string) grpc.UnaryServerInterceptor
GRPCUnaryInterceptor returns a client-side gRPC unary interceptor that populates a logger with trace data in the context.
func HTTPInterceptor ¶ added in v0.1.2
HTTPInterceptor returns an HTTP middleware that populates a logger with trace data onto the incoming and outgoing http.Request context.
func NewFromEnv ¶
func NewFromEnv(envPrefix string) *zap.SugaredLogger
NewFromEnv creates a new logger from env vars. Set envPrefix+"LOG_LEVEL" to overwrite log level. Default log level is warning. Set envPrefix+"LOG_MODE" to overwrite log mode. Default log mode is production.
func TestLogger ¶
func TestLogger(tb zaptest.TestingT, opts ...zaptest.LoggerOption) *zap.SugaredLogger
TestLogger returns a logger configured for tests. It will only output log information if specific test fails or is run in verbose mode. See zaptest for more information.
func TestMyThing(t *testing.T) {
logger := logging.TestLogger(t)
thing := &MyThing{logger: logger}
}
func WithLogger ¶
WithLogger creates a new context with the provided logger attached.
Types ¶
This section is empty.