log

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2020 License: BSD-3-Clause Imports: 11 Imported by: 10

Documentation

Index

Constants

View Source
const (
	EnvKeyLogCtx         = "FLOGO_LOG_CTX"
	EnvFileName          = "FLOGO_FILE_NAME"
	EnvKeyLogDateFormat  = "FLOGO_LOG_DTFORMAT"
	DefaultLogDateFormat = "2006-01-02 15:04:05.000"
	EnvKeyLogLevel       = "FLOGO_LOG_LEVEL"
	DefaultLogLevel      = ErrorLevel
	EnvKeyLogFormat      = "FLOGO_LOG_FORMAT"
	DefaultLogFormat     = FormatConsole

	TraceLevel Level = iota
	DebugLevel
	InfoLevel
	WarnLevel
	ErrorLevel

	FormatConsole Format = iota
	FormatJson
)
View Source
const (
	LogFileName = "flogo_"
)

Variables

This section is empty.

Functions

func CtxLoggingEnabled

func CtxLoggingEnabled() bool

func Init added in v1.1.2

func Init(option *Option)

func NewZapLogger added in v1.0.9

func NewZapLogger(opt *Opt) (*zap.Logger, io.Writer)

func SetLogLevel

func SetLogLevel(logger Logger, level Level)

func Sync

func Sync()

func SyncEx added in v1.1.3

func SyncEx()

Types

type Field

type Field = interface{}

func FieldAny

func FieldAny(key string, val interface{}) Field

func FieldBinary

func FieldBinary(key string, val []byte) Field

func FieldBool

func FieldBool(key string, val bool) Field

func FieldBools

func FieldBools(key string, vals []bool) Field

func FieldByteString

func FieldByteString(key string, val []byte) Field

func FieldByteStrings

func FieldByteStrings(key string, vals [][]byte) Field

func FieldDuration

func FieldDuration(key string, val time.Duration) Field

func FieldDurations

func FieldDurations(key string, vals []time.Duration) Field

func FieldError

func FieldError(err error) Field

func FieldErrors

func FieldErrors(key string, errs []error) Field

func FieldFloat32

func FieldFloat32(key string, val float32) Field

func FieldFloat32s

func FieldFloat32s(key string, vals []float32) Field

func FieldFloat64

func FieldFloat64(key string, val float64) Field

func FieldFloat64s

func FieldFloat64s(key string, vals []float64) Field

func FieldInt

func FieldInt(key string, val int) Field

func FieldInt32

func FieldInt32(key string, val int32) Field

func FieldInt64

func FieldInt64(key string, val int64) Field

func FieldInt64s

func FieldInt64s(key string, vals []int64) Field

func FieldInts

func FieldInts(key string, vals []int) Field

func FieldNamedError

func FieldNamedError(key string, err error) Field

func FieldNamespace

func FieldNamespace(key string) Field

Namespace see zap.Namespace

func FieldObject

func FieldObject(key string, val interface{}) Field

Object encodes object using reflection

func FieldSkip

func FieldSkip() Field

Skip see zap.Skip

func FieldStack

func FieldStack(key string) Field

func FieldString

func FieldString(key string, val string) Field

func FieldStringer

func FieldStringer(key string, val fmt.Stringer) Field

func FieldStrings

func FieldStrings(key string, vals []string) Field

func FieldTime

func FieldTime(key string, val time.Time) Field

func FieldTimes

func FieldTimes(key string, vals []time.Time) Field

type Format

type Format int

type Level

type Level int
const (
	DEBUG Level = iota
	INFO
	WARN
	ERROR
	FATAL
)

func ToLogLevel

func ToLogLevel(lvlStr string) Level

func (*Level) Unmarshal added in v1.0.9

func (l *Level) Unmarshal(text string)

type Logger

type Logger interface {
	DebugEnabled() bool
	TraceEnabled() bool

	Trace(args ...interface{})
	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})

	Tracef(template string, args ...interface{})
	Debugf(template string, args ...interface{})
	Infof(template string, args ...interface{})
	Warnf(template string, args ...interface{})
	Errorf(template string, args ...interface{})

	Structured() StructuredLogger
}

func ChildLogger

func ChildLogger(logger Logger, name string) Logger

func ChildLoggerWithFields

func ChildLoggerWithFields(logger Logger, fields ...Field) Logger

func GetLoggerEx added in v1.1.6

func GetLoggerEx() Logger

func RootLogger

func RootLogger() Logger

type Opt added in v1.0.9

type Opt struct {
	LogPath    string
	LogName    string
	LogLevel   string
	MaxSize    int
	MaxBackup  int
	MaxAge     int
	LogOutput  Output
	JsonFormat bool
}

type Option added in v1.1.6

type Option struct {
	LogPath    string `json:"logPath"`
	LogName    string `json:"logName"`
	LogLevel   string `json:"logLevel"` //0 debug,1 info,2 warn,3 error,4 fatal
	MaxSize    int    `json:"maxSize"`  //日志分割的尺寸 MB
	MaxBackup  int    `json:"maxBackup"`
	MaxAge     int    `json:"maxAge"` //分割日志保存的时间 day
	JsonFormat bool   `json:"JsonFormat"`
}

type Output added in v1.0.9

type Output int
const (
	FILE Output = iota
	CONSOLE
	ALL
)

type StructuredLogger

type StructuredLogger interface {
	Debug(msg string, fields ...Field)
	Info(msg string, fields ...Field)
	Warn(msg string, fields ...Field)
	Error(msg string, fields ...Field)
}

Jump to

Keyboard shortcuts

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