Documentation
¶
Index ¶
- Constants
- type Caller
- type Core
- type Err
- type Level
- type Option
- type Rotation
- type SentryConfig
- type SentryEnvironment
- type TimeFormat
- type Zap
- func (z *Zap) DPanic(args ...any)
- func (z *Zap) DPanicF(message string, args ...any)
- func (z *Zap) DPanicW(message string, keyAndValues ...any)
- func (z *Zap) Debug(args ...any)
- func (z *Zap) DebugF(message string, args ...any)
- func (z *Zap) DebugW(message string, keyAndValues ...any)
- func (z *Zap) Error(args ...any)
- func (z *Zap) ErrorF(message string, args ...any)
- func (z *Zap) ErrorW(message string, keyAndValues ...any)
- func (z *Zap) Fatal(args ...any)
- func (z *Zap) FatalF(message string, args ...any)
- func (z *Zap) FatalW(message string, keyAndValues ...any)
- func (z *Zap) GetSentryClient() *sentry.Client
- func (z *Zap) GetServiceCode() uint
- func (z *Zap) GetServiceName() string
- func (z *Zap) GetZap() *zap.Logger
- func (z *Zap) Info(args ...any)
- func (z *Zap) InfoF(message string, args ...any)
- func (z *Zap) InfoW(message string, keyAndValues ...any)
- func (z *Zap) NewCore(cores ...Core) error
- func (z *Zap) Panic(args ...any)
- func (z *Zap) PanicF(message string, args ...any)
- func (z *Zap) PanicW(message string, keyAndValues ...any)
- func (z *Zap) Warn(args ...any)
- func (z *Zap) WarnF(message string, args ...any)
- func (z *Zap) WarnW(message string, keyAndValues ...any)
- type Zapper
Constants ¶
const ( CONSOLE coreType = iota SENTRY FILE JSON )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Caller ¶
type Caller interface { Debug(...any) DebugF(string, ...any) DebugW(string, ...any) Info(...any) InfoF(string, ...any) InfoW(string, ...any) Warn(...any) WarnF(string, ...any) WarnW(string, ...any) Error(...any) ErrorF(string, ...any) ErrorW(string, ...any) DPanic(...any) DPanicF(string, ...any) DPanicW(string, ...any) Panic(...any) PanicF(string, ...any) PanicW(string, ...any) Fatal(...any) FatalF(string, ...any) FatalW(string, ...any) }
type Core ¶
type Core interface {
// contains filtered or unexported methods
}
Core zapper base abstract
func ConsoleWriterCore ¶
ConsoleWriterCore create console writer for zapper to show log in console
func FileWriterCore ¶ added in v1.1.0
FileWriterCore write logs into file
func JsonWriterCore ¶ added in v1.3.0
JsonWriterCore write logs with json format, fileExtension is for set output file extension json,log and etc
func SentryCore ¶
func SentryCore(dsn string, serverName string, environment SentryEnvironment, cfg *SentryConfig) Core
SentryCore send log into sentry service
type Level ¶
Level zapper levels
const ( Debug Level = iota - 1 // Debug logs are typically voluminous, and are usually disabled in production Info // Info is the default logging priority Warn // Warn logs are more important than Info, but don't need individual human review Error // Error logs are high-priority. If an application is running smoothly, it shouldn't generate any error-level logs DPanic // DPanic logs are particularly important errors. In development the logger panics after writing the message Panic // Panic logs a message, then panics Fatal // Fatal logs a message, then calls os.Exit(1) )
type Option ¶
type Option func(*Zap)
func WithCustomStackTraceLevel ¶
WithCustomStackTraceLevel set custom level for show stacktrace, min level warn
func WithServiceDetails ¶ added in v1.2.0
WithServiceDetails set service name for zapper and show service name for log files
func WithTimeFormat ¶
func WithTimeFormat(format TimeFormat) Option
WithTimeFormat set custom time format for zapper logs
type Rotation ¶
type Rotation struct { MaxAge int // MaxAge is the maximum number of days to retain old log files based on the timestamp encoded in their filename. Note that a day is defined as 24 hours and may not exactly correspond to calendar days due to daylight savings, leap seconds, etc. The default is not to remove old log files based on age. FileSize int // FileSize is the maximum size in megabytes of the log file before it gets rotated. It defaults to 100 megabytes Compress bool // Compress determines if the rotated log files should be compressed using gzip. The default is not to perform compression }
Rotation config log file rotation in log path
type SentryConfig ¶
type SentryConfig struct { AttachStacktrace bool // AttachStacktrace attach stacktrace to event Debug bool // Debug add debug data to event EnableTracing bool Environment string Dist string EnableBreadcrumbs bool BreadcrumbLevel Level MaxBreadcrumbs int MaxSpans int Tags map[string]string MinLevel Level FlushTimeout time.Duration }
SentryConfig for sentry core set custom configs
type SentryEnvironment ¶ added in v1.4.0
type SentryEnvironment int
const ( DEVELOPMENT SentryEnvironment = iota // DEVELOPMENT application environment PRODUCTION // PRODUCTION application environment )
func (SentryEnvironment) String ¶ added in v1.4.0
func (e SentryEnvironment) String() string
type TimeFormat ¶
type TimeFormat int
TimeFormat set custom time format for zap log
const ( ISO8601 TimeFormat = iota // ISO8601 serializes a time.Time to an ISO8601-formatted string with millisecond precision RFC3339 // RFC3339 serializes a time.Time to an RFC3339-formatted string RFC3339NANO // RFC3339NANO serializes a time.Time to an RFC3339-formatted string with nanosecond precision )
func (TimeFormat) String ¶
func (i TimeFormat) String() string
type Zap ¶
type Zap struct {
// contains filtered or unexported fields
}
func (*Zap) DPanic ¶
DPanic uses fmt.Sprint to construct and log a message. In development, the logger then panics. (See DPanicLevel for details.)
func (*Zap) DPanicF ¶
DPanicF uses fmt.Sprintf to log a templated message. In development, the logger then panics. (See DPanicLevel for details.)
func (*Zap) DPanicW ¶
DPanicW logs a message with some additional context. In development, the logger then panics. (See DPanicLevel for details.) The variadic key-value pairs are treated as they are in With
func (*Zap) DebugW ¶
DebugW logs a message with some additional context. The variadic key-value pairs are treated as they are in With.
When debug-level logging is disabled, this is much faster than
s.With(keysAndValues).Debug(msg)
func (*Zap) ErrorW ¶
ErrorW logs a message with some additional context. The variadic key-value pairs are treated as they are in With
func (*Zap) FatalW ¶
FatalW logs a message with some additional context, then calls os.Exit. The variadic key-value pairs are treated as they are in With
func (*Zap) GetSentryClient ¶ added in v1.4.0
func (z *Zap) GetSentryClient() *sentry.Client
func (*Zap) GetServiceCode ¶ added in v1.2.0
func (*Zap) GetServiceName ¶ added in v1.2.0
func (*Zap) InfoW ¶
InfoW logs a message with some additional context. The variadic key-value pairs are treated as they are in With
func (*Zap) PanicW ¶
PanicW logs a message with some additional context, then panics. The variadic key-value pairs are treated as they are in With