package
1.1.3
Repository: https://github.com/go-spring/spring-base.git
Documentation: pkg.go.dev

# README

log

重新定义标准日志接口,可以灵活适配各种日志框架。

Install

go get github.com/go-spring/[email protected] 

Import

import "github.com/go-spring/spring-base/log"

Example

log.SetLevel(log.TraceLevel)
defer log.Reset()

log.Trace("a", "=", "1")
log.Tracef("a=%d", 1)

log.Trace(func() []interface{} {
    return log.T("a", "=", "1")
})

log.Tracef("a=%d", func() []interface{} {
    return log.T(1)
})

...
ctx := context.WithValue(context.TODO(), traceIDKey, "0689")

log.SetLevel(log.TraceLevel)
log.SetOutput(myOutput)
defer log.Reset()

logger := log.Ctx(ctx)
logger.Trace("level:", "trace")
logger.Tracef("level:%s", "trace")

...

logger = log.Tag("__in")
logger.Ctx(ctx).Trace("level:", "trace")
logger.Ctx(ctx).Tracef("level:%s", "trace")

...

# Packages

No description provided by the author
No description provided by the author

# Functions

Any takes a key and an arbitrary value and chooses the best way to represent them as a field, falling back to a reflection-based approach only if necessary.
Array constructs a field that carries a slice of Value.
Bool constructs a field that carries a bool.
BoolPtr constructs a field that carries a *bool.
Bools constructs a field that carries a slice of bool.
Float32 constructs a field that carries a float32.
Float32Ptr constructs a field that carries a *float32.
Float32s constructs a field that carries a slice of float32.
Float64 constructs a field that carries a float64.
Float64Ptr constructs a field that carries a *float64.
Float64s constructs a field that carries a slice of float64.
No description provided by the author
Int constructs a field that carries an int.
Int16 constructs a field that carries an int16.
Int16Ptr constructs a field that carries a *int16.
Int16s constructs a field that carries a slice of int16.
Int32 constructs a field that carries an int32.
Int32Ptr constructs a field that carries a *int32.
Int32s constructs a field that carries a slice of int32.
Int64 constructs a field that carries an int64.
Int64Ptr constructs a field that carries a *int64.
Int64s constructs a field that carries a slice of int64.
Int8 constructs a field that carries an int8.
Int8Ptr constructs a field that carries a *int8.
Int8s constructs a field that carries a slice of int8.
IntPtr constructs a field that carries a *int.
Ints constructs a field that carries a slice of int.
NewFileWriter returns a FileWriter that a Writer implementation.
NewFlatEncoder return a new *FlatEncoder with separator.
NewJSONEncoder returns a new *JSONEncoder.
Nil constructs a field that carries a nil.
Object constructs a field that carries a slice of Field.
ParseColorStyle parses `s` to a ColorStyle value.
ParseLevel parses string to a level, and returns error if the conversion fails.
No description provided by the author
Reflect constructs a field that carries an interface{}, which should be serialized using reflection.
Refresh 加载日志配置文件。.
RefreshBuffer 加载日志配置文件。.
RefreshReader 加载日志配置文件。.
RegisterConverter registers Converter for non-primitive type such as time.Time, time.Duration, or other user-defined value type.
RegisterPlugin registers a Plugin, `i` is used to obtain the type of Plugin.
RegisterReader 注册配置项解析器。.
String constructs a field that carries a string.
StringPtr constructs a field that carries a *string.
Strings constructs a field that carries a slice of string.
Uint constructs a field that carries an uint.
Uint16 constructs a field that carries an uint16.
Uint16Ptr constructs a field that carries a *uint16.
Uint16s constructs a field that carries a slice of uint16.
Uint32 constructs a field that carries an uint32.
Uint32Ptr constructs a field that carries a *uint32.
Uint32s constructs a field that carries a slice of uint32.
Uint64 constructs a field that carries an uint64.
Uint64Ptr constructs a field that carries a *uint64.
Uint64s constructs a field that carries a slice of uint64.
Uint8 constructs a field that carries an uint8.
Uint8Ptr constructs a field that carries a *uint8.
Uint8s constructs a field that carries a slice of uint8.
UintPtr constructs a field that carries a *uint.
Uints constructs a field that carries a slice of uint.
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

Writers manages the Get and Release of Writer(s).

# Structs

AcceptAllFilter causes all logging events to be accepted.
AppenderRef is a reference to an Appender.
No description provided by the author
No description provided by the author
ConsoleAppender is an Appender that writing messages to os.Stdout.
DenyAllFilter causes all logging events to be dropped.
Entry
Entry is an Entry implementation that has context and errno.
Event provides contextual information about a log message.
Field is used to replace printf operation with lower cost.
FileAppender is an Appender writing messages to *os.File.
FileWriter is a Writer implementation by *os.File.
FlatEncoder encodes Fields in flat format.
JSONEncoder encodes Fields in json format.
A JSONLayout is a layout configurable with JSON encoding.
LevelFilter logs events if the level in the Event is same or more specific than the configured level.
LevelMatchFilter logs events if the level in the Event matches the specified logging level exactly.
LevelRangeFilter logs events if the level in the Event is in the range of the configured min and max levels.
No description provided by the author
No description provided by the author
NullAppender is an Appender that ignores log events.
A PatternLayout is a flexible layout configurable with pattern string.
Plugin is the name of node label or XML element.
ReflectValue represents an interface{} carried by Field.
No description provided by the author
No description provided by the author
TimeFilter filters events that fall within a specified time period in each day.
No description provided by the author

# Interfaces

Appender represents an output destination.
An Encoder is used to serialize strongly-typed Field.
Filter is an interface that tells the logger a log message should be dropped when the Filter method returns ResultDeny.
No description provided by the author
Layout lays out an Event in []byte format.
No description provided by the author
Reader 配置项解析器。.
Value represents a data and encodes it to an Encoder.
Writer is io.Writer with a name and a Stop method.

# Type aliases

ArrayValue represents a slice of Value carried by Field.
BoolsValue represents a slice of bool carried by Field.
BoolValue represents a bool carried by Field.
No description provided by the author
Float32sValue represents a slice of float32 carried by Field.
Float64sValue represents a slice of float64 carried by Field.
Float64Value represents a float64 carried by Field.
No description provided by the author
Int16sValue represents a slice of int16 carried by Field.
Int32sValue represents a slice of int32 carried by Field.
Int64sValue represents a slice of int64 carried by Field.
Int64Value represents a int64 carried by Field.
Int8sValue represents a slice of int8 carried by Field.
IntsValue represents a slice of int carried by Field.
Level used for identifying the severity of an event.
ObjectValue represents a slice of Field carried by Field.
No description provided by the author
No description provided by the author
No description provided by the author
StringsValue represents a slice of string carried by Field.
StringValue represents a string carried by Field.
No description provided by the author
Uint16sValue represents a slice of uint16 carried by Field.
Uint32sValue represents a slice of uint32 carried by Field.
Uint64sValue represents a slice of uint64 carried by Field.
Uint64Value represents a uint64 carried by Field.
Uint8sValue represents a slice of uint8 carried by Field.
UintsValue represents a slice of uint carried by Field.