logcontext

package module
v0.0.0-...-bbeb532 Latest Latest
Warning

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

Go to latest
Published: May 8, 2019 License: MIT Imports: 7 Imported by: 0

README

logcontext

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

func Debugc

func Debugc(ctx context.Context, v ...interface{})

func Debugcf

func Debugcf(ctx context.Context, format string, v ...interface{})

func Debugf

func Debugf(format string, v ...interface{})

func Debugw

func Debugw(msg string, f ...zap.Field)

func Debugwc

func Debugwc(ctx context.Context, msg string, f ...zap.Field)

Types

type Color

type Color uint8

Color represents a text color.

const (
	Black Color = iota + 30
	Red
	Green
	Yellow
	Blue
	Magenta
	Cyan
	White
)

Foreground colors.

func (Color) Add

func (c Color) Add(s string) string

Add adds the coloring to the given string.

type ContextLog

type ContextLog interface {
	ContextInfo(ctx context.Context) []zap.Field
	ContextStr(ctx context.Context) string
}

func NewNilContext

func NewNilContext() ContextLog

func NewTraceContext

func NewTraceContext() ContextLog

type LogContext

type LogContext interface {
	SetContextLog(c ContextLog) LogContext
	SetLogLevel(level LogLevel) LogContext
	SetCallerSkip(calldepth int) LogContext

	Sync()

	Debug(v ...interface{})
	Debugf(format string, v ...interface{})
	Debugc(ctx context.Context, v ...interface{})
	Debugcf(ctx context.Context, format string, v ...interface{})
	Debugw(msg string, f ...zap.Field)
	Debugwc(ctx context.Context, msg string, f ...zap.Field)

	Info(v ...interface{})
	Infof(format string, v ...interface{})
	Infoc(ctx context.Context, v ...interface{})
	Infocf(ctx context.Context, format string, v ...interface{})
	Infow(msg string, f ...zap.Field)
	Infowc(ctx context.Context, msg string, f ...zap.Field)

	Print(v ...interface{})
	Println(v ...interface{})
	Printf(format string, v ...interface{})

	Warn(v ...interface{})
	Warnf(format string, v ...interface{})
	Warnc(ctx context.Context, v ...interface{})
	Warncf(ctx context.Context, format string, v ...interface{})
	Warnw(msg string, f ...zap.Field)
	Warnwc(ctx context.Context, msg string, f ...zap.Field)

	Error(v ...interface{})
	Errorf(format string, v ...interface{})
	Errorc(ctx context.Context, v ...interface{})
	Errorcf(ctx context.Context, format string, v ...interface{})
	Errorw(msg string, f ...zap.Field)
	Errorwc(ctx context.Context, msg string, f ...zap.Field)

	Fatal(v ...interface{})
	Fatalf(format string, v ...interface{})
	Fatalc(ctx context.Context, v ...interface{})
	Fatalcf(ctx context.Context, format string, v ...interface{})
	Fatalw(msg string, f ...zap.Field)
	Fatalwc(ctx context.Context, msg string, f ...zap.Field)

	Panic(v ...interface{})
	Panicf(format string, v ...interface{})
	Panicc(ctx context.Context, v ...interface{})
	Paniccf(ctx context.Context, format string, v ...interface{})
	Panicw(msg string, f ...zap.Field)
	Panicwc(ctx context.Context, msg string, f ...zap.Field)
}

func NewDefStdLog

func NewDefStdLog() LogContext

func NewZapLog

func NewZapLog(zlog *zap.Logger, atom zap.AtomicLevel, encoding string) (zl LogContext)

func SetCallerSkip

func SetCallerSkip(calldepth int) LogContext

func SetContextLog

func SetContextLog(c ContextLog) LogContext

func SetLog

func SetLog(log LogContext) LogContext

func SetLogLevel

func SetLogLevel(level LogLevel) LogContext

type LogLevel

type LogLevel int
const (
	// FatalLevel logs are typically voluminous, and are usually disabled in
	// production.
	DebugLevel LogLevel = iota - 1
	// InfoLevel is the default logging priority.
	InfoLevel
	// WarnLevel logs are more important than Info, but don't need individual
	// human review.
	WarnLevel
	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-level logs.
	ErrorLevel
	// DPanicLevel logs are particularly important errors. In development the
	// logger panics after writing the message.
	DPanicLevel
	// PanicLevel logs a message, then panics.
	PanicLevel
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel
)

type TraceContext

type TraceContext struct {
	KInfo string
}

func (*TraceContext) ContextInfo

func (tContext *TraceContext) ContextInfo(ctx context.Context) []zap.Field

func (*TraceContext) ContextStr

func (tContext *TraceContext) ContextStr(ctx context.Context) string

Jump to

Keyboard shortcuts

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