Documentation
¶
Index ¶
- Constants
- func NewEmbbedLogger(runtimeLevel byte, loggerName string) *logger
- type Appender
- type CompositeLogger
- type Field
- func Any(key string, value interface{}) Field
- func Binary(key string, val []byte) Field
- func Bool(key string, val bool) Field
- func ByteString(key string, val []byte) Field
- func Complex128(key string, val complex128) Field
- func Complex64(key string, val complex64) Field
- func Duration(key string, val time.Duration) Field
- func Float32(key string, val float32) Field
- func Float64(key string, val float64) Field
- func Int(key string, val int) Field
- func Int16(key string, val int16) Field
- func Int32(key string, val int32) Field
- func Int64(key string, val int64) Field
- func Int8(key string, val int8) Field
- func Namespace(key string) Field
- func Reflect(key string, val interface{}) Field
- func String(key string, val string) Field
- func Stringer(key string, val fmt.Stringer) Field
- func Time(key string, val time.Time) Field
- func Uint(key string, val uint) Field
- func Uint16(key string, val uint16) Field
- func Uint32(key string, val uint32) Field
- func Uint64(key string, val uint64) Field
- func Uint8(key string, val uint8) Field
- func Uintptr(key string, val uintptr) Field
- type FieldType
- type Layout
- type Logger
- type LoggerFactory
- type Option
- type StructBean
- type StructLoggerRegister
Constants ¶
const ( DEBUG = 1 INFO = 2 WARN = 3 ERROR = 4 FATAL = 5 )
define delvel const for object
Variables ¶
This section is empty.
Functions ¶
func NewEmbbedLogger ¶
Types ¶
type Appender ¶
type Appender interface { GetAppenderName() string // Initialize appender Initialize() // set the layout SetLayout(layout Layout) // get open layout GetLayout() Layout }
Appender appender struct
type CompositeLogger ¶
type CompositeLogger interface { Logger SetParentLogger(parentLogger Logger) GetParentLogger() Logger }
CompositeLogger with parent logger define
type Field ¶ added in v0.1.2
func Any ¶ added in v0.1.2
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.
Since byte/uint8 and rune/int32 are aliases, Any can't differentiate between them. To minimize surprises, []byte values are treated as binary blobs, byte values are treated as uint8, and runes are always treated as integers.
func Binary ¶ added in v0.1.2
Binary data is serialized in an encoding-appropriate format. For example, zap's JSON encoder base64-encodes binary blobs. To log UTF-8 encoded text, use ByteString.
func ByteString ¶ added in v0.1.2
ByteString constructs a field that carries UTF-8 encoded text as a []byte. To log opaque binary blobs (which aren't necessarily valid UTF-8), use Binary.
func Complex128 ¶ added in v0.1.2
func Complex128(key string, val complex128) Field
Complex128 constructs a field that carries a complex number. Unlike most numeric fields, this costs an allocation (to convert the complex128 to interface{}).
func Complex64 ¶ added in v0.1.2
Complex64 constructs a field that carries a complex number. Unlike most numeric fields, this costs an allocation (to convert the complex64 to interface{}).
func Duration ¶ added in v0.1.2
Duration constructs a field with the given key and value. The encoder controls how the duration is serialized.
func Float32 ¶ added in v0.1.2
Float32 constructs a field that carries a float32. The way the floating-point value is represented is encoder-dependent, so marshaling is necessarily lazy.
func Float64 ¶ added in v0.1.2
Float64 constructs a field that carries a float64. The way the floating-point value is represented is encoder-dependent, so marshaling is necessarily lazy.
func Namespace ¶ added in v0.1.2
Namespace creates a named, isolated scope within the logger's context. All subsequent fields will be added to the new namespace.
This helps prevent key collisions when injecting loggers into sub-components or third-party libraries.
func Reflect ¶ added in v0.1.2
Reflect constructs a field with the given key and an arbitrary object. It uses an encoding-appropriate, reflection-based function to lazily serialize nearly any object into the logging context, but it's relatively slow and allocation-heavy. Outside tests, Any is always a better choice.
If encoding fails (e.g., trying to serialize a map[int]string to JSON), Reflect includes the error message in the final log output.
func Stringer ¶ added in v0.1.2
Stringer constructs a field with the given key and the output of the value's String method. The Stringer's String method is called lazily.
func Time ¶ added in v0.1.2
Time constructs a Field with the given key and value. The encoder controls how the time is serialized.
type FieldType ¶ added in v0.1.2
type FieldType uint8
const ( // UnknownType is the default field type. Attempting to add it to an encoder will panic. UnknownType FieldType = iota // ArrayMarshalerType indicates that the field carries an ArrayMarshaler. ArrayMarshalerType // ObjectMarshalerType indicates that the field carries an ObjectMarshaler. ObjectMarshalerType // BinaryType indicates that the field carries an opaque binary blob. BinaryType // BoolType indicates that the field carries a bool. BoolType // ByteStringType indicates that the field carries UTF-8 encoded bytes. ByteStringType // Complex128Type indicates that the field carries a complex128. Complex128Type // Complex64Type indicates that the field carries a complex128. Complex64Type // DurationType indicates that the field carries a time.Duration. DurationType // Float64Type indicates that the field carries a float64. Float64Type // Float32Type indicates that the field carries a float32. Float32Type // Int64Type indicates that the field carries an int64. Int64Type // Int32Type indicates that the field carries an int32. Int32Type // Int16Type indicates that the field carries an int16. Int16Type // Int8Type indicates that the field carries an int8. Int8Type // StringType indicates that the field carries a string. StringType // TimeType indicates that the field carries a time.Time. TimeType // Uint64Type indicates that the field carries a uint64. Uint64Type // Uint32Type indicates that the field carries a uint32. Uint32Type // Uint16Type indicates that the field carries a uint16. Uint16Type // Uint8Type indicates that the field carries a uint8. Uint8Type // UintptrType indicates that the field carries a uintptr. UintptrType // ReflectType indicates that the field carries an interface{}, which should // be serialized using reflection. ReflectType // NamespaceType signals the beginning of an isolated namespace. All // subsequent fields should be added to the new namespace. NamespaceType // StringerType indicates that the field carries a fmt.Stringer. StringerType // ErrorType indicates that the field carries an error. ErrorType // SkipType indicates that the field is a no-op. SkipType )
type Layout ¶
type Layout interface { SetCharset(cs string) // SetLayoutProps check the layout props is supported or not SetLayoutProps(props map[string]string) error // SetPattern use pattern format of log4j2 SetPattern(pattern []byte) }
Layout layout is api for display layout format in output
type Logger ¶
type Logger interface { // define logger name GetName() string // ---- IsDebugEnabled() bool IsInfoEnabled() bool IsWarnEnabled() bool IsErrorEnabled() bool IsFatalEnabled() bool Debug(msg string, logbean StructBean) Info(msg string, logbean StructBean) Warn(msg string, logbean StructBean) Error(msg string, logbean StructBean) Fatal(msg string, logbean StructBean) }
Logger create binder interface
func GetLogger ¶
GetLogger define the custom logger , loggername is mark for identifing logger function . get close patten logger
func RegisterLoggerFactory ¶
func RegisterLoggerFactory(reg StructLoggerRegister, opts ...Option) ([]Logger, error)
LoggerFactoryRegister create new logger factory manager by logger provider register
type LoggerFactory ¶
type LoggerFactory interface { // NewStructBean define NewLoggerBean() StructBean // CreateLogger get the base logger GetLogger() Logger }
LoggerFactory define the base logger factory manager
type Option ¶
type Option interface { // GetLevel return the base level object GetLevel() string // SetLoggerPattern define logger pattern for match loggger name SetLoggerPattern(loggerPattern string) // GetLoggerPattern get logger pattern GetLoggerPattern() string // SetAdditivity default is true , set the value is false . log info would be output in private . SetAdditivity(newadditivity bool) // GetAdditivity get the Additivity status GetAdditivity() bool // GetProperties get the append value GetProperties() map[string]string // GetAppender get the all appender GetAppenders() map[string]Appender }
Option this Logger option is a interface for every implement package
type StructBean ¶
type StructBean interface { LogBinary(key string, value []byte) LogByteString(key string, values []byte) LogByteStringArray(key string, values [][]byte) // LogString log message string LogString(string, string) LogStringArray(key string, values []string) LogBool(key string, value bool) LogBoolArray(key string, values []bool) LogInt8(string, int8) LogInt8Array(key string, nums []int8) LogInt(string, int) LogIntArray(key string, nums []int) LogInt16(key string, value int16) LogInt16Array(key string, nums []int16) LogInt32(key string, value int32) LogInt32Array(key string, nums []int32) LogInt64(key string, value int64) LogInt64Array(key string, nums []int64) LogUint8(key string, value uint8) LogUint8Array(key string, nums []uint8) LogUint(key string, value uint) LogUintArray(key string, nums []uint) LogUint16(key string, value uint16) LogUint16Array(key string, nums []uint16) LogUint32(key string, value uint32) LogUint32Array(key string, nums []uint32) LogFloat32(key string, value float32) LogFloat32Array(key string, values []float32) LogFloat64(key string, value float64) LogFloat64Array(key string, values []float64) LogDuration(key string, value time.Duration) LogDurationArray(key string, values []time.Duration) LogTime(key string, value time.Time) LogTimeArray(key string, values []time.Time) }
StructBean Message object is logger info use common
func NewStructBean ¶
func NewStructBean() StructBean
NewStructBean create new struct bean for struct logger message
type StructLoggerRegister ¶
type StructLoggerRegister interface { // CreateLogger return the instance logger with multiopts CreateLogger(multiopts ...Option) ([]Logger, error) // CreateStructBean CreateStructBean() StructBean }
StructLoggerRegister the interface provide the factory register