Documentation
¶
Index ¶
- Constants
- func Ctx(ctx context.Context) otelzap.LoggerWithCtx
- func DPanic(msg string, fields ...zapcore.Field)
- func DPanicContext(ctx context.Context, msg string, fields ...zapcore.Field)
- func DPanicf(format string, v ...interface{})
- func DPanicfContext(ctx context.Context, format string, v ...interface{})
- func DPanicln(args ...interface{})
- func DPanicw(format string, v ...interface{})
- func DPanicwContext(ctx context.Context, format string, v ...interface{})
- func Debug(msg string, fields ...zapcore.Field)
- func DebugContext(ctx context.Context, msg string, fields ...zapcore.Field)
- func Debugf(format string, v ...interface{})
- func DebugfContext(ctx context.Context, format string, v ...interface{})
- func Debugln(args ...interface{})
- func Debugw(format string, v ...interface{})
- func DebugwContext(ctx context.Context, format string, v ...interface{})
- func Error(msg string, fields ...zapcore.Field)
- func ErrorContext(ctx context.Context, msg string, fields ...zapcore.Field)
- func Errorf(format string, v ...interface{})
- func ErrorfContext(ctx context.Context, format string, v ...interface{})
- func Errorln(args ...interface{})
- func Errorw(format string, v ...interface{})
- func ErrorwContext(ctx context.Context, format string, v ...interface{})
- func Fatal(msg string, fields ...zapcore.Field)
- func FatalContext(ctx context.Context, msg string, fields ...zapcore.Field)
- func Fatalf(format string, v ...interface{})
- func FatalfContext(ctx context.Context, format string, v ...interface{})
- func Fatalln(args ...interface{})
- func Fatalw(format string, v ...interface{})
- func FatalwContext(ctx context.Context, format string, v ...interface{})
- func Flush()
- func Info(msg string, fields ...zapcore.Field)
- func InfoContext(ctx context.Context, msg string, fields ...zapcore.Field)
- func Infof(format string, v ...interface{})
- func InfofContext(ctx context.Context, format string, v ...interface{})
- func Infoln(args ...interface{})
- func Infow(format string, v ...interface{})
- func InfowContext(ctx context.Context, format string, v ...interface{})
- func L() *otelzap.Logger
- func Logger() *otelzap.Logger
- func MustNewLogger(opts ...OptionFunc) *zap.Logger
- func MustNewOtelLogger(opts ...OptionFunc) *otelzap.Logger
- func Panic(msg string, fields ...zapcore.Field)
- func PanicContext(ctx context.Context, msg string, fields ...zapcore.Field)
- func Panicf(format string, v ...interface{})
- func PanicfContext(ctx context.Context, format string, v ...interface{})
- func Panicln(args ...interface{})
- func Panicw(format string, v ...interface{})
- func PanicwContext(ctx context.Context, format string, v ...interface{})
- func S() *otelzap.SugaredLogger
- func Sugar() *otelzap.SugaredLogger
- func Warn(msg string, fields ...zapcore.Field)
- func WarnContext(ctx context.Context, msg string, fields ...zapcore.Field)
- func Warnf(format string, v ...interface{})
- func WarnfContext(ctx context.Context, format string, v ...interface{})
- func Warnln(args ...interface{})
- func Warnw(format string, v ...interface{})
- func WarnwContext(ctx context.Context, format string, v ...interface{})
- type GormLogger
- func (g GormLogger) Error(ctx context.Context, s string, i ...interface{})
- func (g GormLogger) Info(ctx context.Context, s string, i ...interface{})
- func (g GormLogger) LogMode(_ logger.LogLevel) logger.Interface
- func (g GormLogger) Trace(ctx context.Context, begin time.Time, ...)
- func (g GormLogger) Warn(ctx context.Context, s string, i ...interface{})
- type OptionFunc
- func WithColor(on bool) OptionFunc
- func WithDevelopmentLogging(on bool) OptionFunc
- func WithErrLevel(lvl zapcore.Level) OptionFunc
- func WithErrOutPaths(path ...string) OptionFunc
- func WithFormat(format string) OptionFunc
- func WithLevel(lvl zapcore.Level) OptionFunc
- func WithOtelZapOptions(opt ...otelzap.Option) OptionFunc
- func WithOutputPaths(path ...string) OptionFunc
- func WithZapOptions(opt ...zap.Option) OptionFunc
- type Options
Constants ¶
View Source
const ( ConsoleFormat = "console" JsonFormat = "json" )
Variables ¶
This section is empty.
Functions ¶
func DPanicfContext ¶
func DPanicwContext ¶
func DebugfContext ¶
func DebugwContext ¶
func ErrorfContext ¶
func ErrorwContext ¶
func FatalfContext ¶
func FatalwContext ¶
func InfofContext ¶
func InfowContext ¶
func MustNewLogger ¶
func MustNewLogger(opts ...OptionFunc) *zap.Logger
func MustNewOtelLogger ¶
func MustNewOtelLogger(opts ...OptionFunc) *otelzap.Logger
func PanicfContext ¶
func PanicwContext ¶
func S ¶
func S() *otelzap.SugaredLogger
func Sugar ¶
func Sugar() *otelzap.SugaredLogger
func WarnfContext ¶
func WarnwContext ¶
Types ¶
type GormLogger ¶
func MustNewGormLogger ¶
func MustNewGormLogger(l *otelzap.Logger) *GormLogger
func (GormLogger) Error ¶
func (g GormLogger) Error(ctx context.Context, s string, i ...interface{})
type OptionFunc ¶
type OptionFunc func(o *Options)
func WithDevelopmentLogging ¶
func WithDevelopmentLogging(on bool) OptionFunc
创建一个development级别的日志(日志将打印更多信息)
func WithErrLevel ¶
func WithErrLevel(lvl zapcore.Level) OptionFunc
设置被认为错误的日志级别,默认的ErrorLevel为Info级别
func WithErrOutPaths ¶
func WithErrOutPaths(path ...string) OptionFunc
如果使用该函数且path.len>=1,则将不自动使用stderr,除非在path中添加stderr 如果path.len==0或不使用该函数则默认日志输出在stderr中
func WithFormat ¶
func WithFormat(format string) OptionFunc
如果format格式错误或默认则使用console,可选"console"以及"json"
func WithOtelZapOptions ¶
func WithOtelZapOptions(opt ...otelzap.Option) OptionFunc
允许创建时使用otelzap自带的Options
func WithOutputPaths ¶
func WithOutputPaths(path ...string) OptionFunc
如果使用该函数且path.len>=1,则将不自动使用stdout,除非在path中添加stdout 如果path.len==0或不使用该函数则默认日志输出在stdout中
type Options ¶
type Options struct {
OutputPaths []string `json:"output-paths" mapstructure:"output-paths"`
ErrorOutputPaths []string `json:"error-output-paths" mapstructure:"error-output-paths"`
Level zapcore.Level `json:"level" mapstructure:"level"`
ErrorLevel zapcore.Level `json:"error-level" mapstructure:"error-level"`
Format string `json:"format" mapstructure:"format"`
EnableColor bool `json:"enable-color" mapstructure:"enable-color"`
Development bool `json:"development" mapstructure:"development"`
ZapOptions []zap.Option
OtelZapOptions []otelzap.Option
}
Click to show internal directories.
Click to hide internal directories.