zap

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReplaceGlobals

func ReplaceGlobals(logger *zap.Logger) func()

ReplaceGlobals replaces the global Logger and SugaredLogger, and returns a function to restore the original values. It's safe for concurrent use.

Types

type ZapBuilder

type ZapBuilder struct {
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder() *ZapBuilder

func (*ZapBuilder) Build

func (b *ZapBuilder) Build() *zap.Logger

func (*ZapBuilder) CallerSkip

func (b *ZapBuilder) CallerSkip(callerSkip int) *ZapBuilder

CallerSkip sets the caller skip.

CallerSkip increases the number of callers skipped by caller annotation (as enabled by the AddCaller option). When building wrappers around the Logger and SugaredLogger, supplying this Option prevents zap from always reporting the wrapper code as the caller.

func (*ZapBuilder) JSONFormatConsole

func (b *ZapBuilder) JSONFormatConsole() *ZapBuilder

func (*ZapBuilder) JSONFormatFile

func (b *ZapBuilder) JSONFormatFile() *ZapBuilder

func (*ZapBuilder) Level

func (b *ZapBuilder) Level(logLevel zapcore.Level) *ZapBuilder

Level sets the log level.

func (*ZapBuilder) LogPath added in v0.4.0

func (b *ZapBuilder) LogPath(logPath string) *ZapBuilder

func (*ZapBuilder) MaxKeepDays

func (b *ZapBuilder) MaxKeepDays(maxKeepDays int) *ZapBuilder

MaxKeepDays sets the maximum retention days for logs.

func (*ZapBuilder) MaxLogSize

func (b *ZapBuilder) MaxLogSize(maxLogSize int) *ZapBuilder

MaxLogSize sets the maximum size in megabytes of the log file before it gets rotated. It defaults to 100 megabytes.

func (*ZapBuilder) NoCaller

func (b *ZapBuilder) NoCaller() *ZapBuilder

func (*ZapBuilder) NoColors

func (b *ZapBuilder) NoColors() *ZapBuilder

func (*ZapBuilder) NoConsole

func (b *ZapBuilder) NoConsole() *ZapBuilder

func (*ZapBuilder) NoErrSeparate

func (b *ZapBuilder) NoErrSeparate() *ZapBuilder

func (*ZapBuilder) NoLogFile

func (b *ZapBuilder) NoLogFile() *ZapBuilder

func (*ZapBuilder) NoTimestamp

func (b *ZapBuilder) NoTimestamp() *ZapBuilder

func (*ZapBuilder) StacktraceLevel

func (b *ZapBuilder) StacktraceLevel(stacktraceLevel zapcore.Level) *ZapBuilder

StacktraceLevel sets the stacktrace level.

func (*ZapBuilder) TimeLocation

func (b *ZapBuilder) TimeLocation(timeLocation *time.Location) *ZapBuilder

TimeLocation sets the time zone.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL