logger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: GPL-3.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	TraceIDKey      = "trace_id"
	UserUUIDKey     = "user_uuid"
	SpanTitleKey    = "span_title"
	SpanFunctionKey = "span_function"
	VersionKey      = "version"
)

Define key name

Variables

This section is empty.

Functions

func AddHook

func AddHook(hook Hook)

AddHook - Increase log hooks

func Debugf

func Debugf(ctx context.Context, format string, args ...interface{})

Debugf - Write debug log

func Errorf

func Errorf(ctx context.Context, format string, args ...interface{})

Errorf - Write error log

func Fatalf

func Fatalf(ctx context.Context, format string, args ...interface{})

Fatalf Write a major error log

func FromTraceIDContext

func FromTraceIDContext(ctx context.Context) string

FromTraceIDContext - Get the tracking ID from the context

func FromUserUUIDContext

func FromUserUUIDContext(ctx context.Context) string

FromUserUUIDContext - Get the user ID from the context

func Infof

func Infof(ctx context.Context, format string, args ...interface{})

Infof - Write to the message log

func NewTraceIDContext

func NewTraceIDContext(ctx context.Context, traceID string) context.Context

NewTraceIDContext - Create a tracking ID context

func NewUserUUIDContext

func NewUserUUIDContext(ctx context.Context, userUUID string) context.Context

NewUserUUIDContext - Create a user ID context

func Printf

func Printf(ctx context.Context, format string, args ...interface{})

Printf - Write to the message log

func SetFormatter

func SetFormatter(format string)

SetFormatter - Set the log output format

func SetLevel

func SetLevel(level int)

SetLevel - Set the log level

func SetOutput

func SetOutput(out io.Writer)

SetOutput - Set log output

func SetTraceIDFunc

func SetTraceIDFunc(fn TraceIDFunc)

SetTraceIDFunc - Set the processing function of the tracking ID

func SetVersion

func SetVersion(v string)

SetVersion - Setting version

func StartSpanWithCall

func StartSpanWithCall(ctx context.Context, opts ...SpanOption) func() *Entry

StartSpanWithCall - Start a tracking unit (callback execution)

func Warnf

func Warnf(ctx context.Context, format string, args ...interface{})

Warnf - Write warning log

Types

type Entry

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

Entry - Define a unified log write mode

func StartSpan

func StartSpan(ctx context.Context, opts ...SpanOption) *Entry

StartSpan - Start a tracking unit

func (*Entry) Debugf

func (e *Entry) Debugf(format string, args ...interface{})

Debugf - Write debug log

func (*Entry) Errorf

func (e *Entry) Errorf(format string, args ...interface{})

Errorf - Error log

func (*Entry) Fatalf

func (e *Entry) Fatalf(format string, args ...interface{})

Fatalf - Major error log

func (*Entry) Infof

func (e *Entry) Infof(format string, args ...interface{})

Infof - Message log

func (*Entry) Printf

func (e *Entry) Printf(format string, args ...interface{})

Printf - Message log

func (*Entry) Warnf

func (e *Entry) Warnf(format string, args ...interface{})

Warnf - Warning log

func (*Entry) WithField

func (e *Entry) WithField(key string, value interface{}) *Entry

WithField - Structured field write

func (*Entry) WithFields

func (e *Entry) WithFields(fields map[string]interface{}) *Entry

WithFields - Structured field write

type Hook

type Hook = logrus.Hook

Hook - Define a log hook alias

type Logger

type Logger = logrus.Logger

Logger - Define a log alias

func StandardLogger

func StandardLogger() *Logger

StandardLogger - Get standard logs

type SpanOption

type SpanOption func(*spanOptions)

SpanOption - Define the data item of the tracking unit

func SetSpanFuncName

func SetSpanFuncName(funcName string) SpanOption

SetSpanFuncName - Set the function name of the tracking unit

func SetSpanTitle

func SetSpanTitle(title string) SpanOption

SetSpanTitle - Set the title of the tracking unit

type TraceIDFunc

type TraceIDFunc func() string

TraceIDFunc - Define the function to get the tracking ID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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