log

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: MIT Imports: 25 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CoreType_name = map[int32]string{
		0: "Unkown",
		1: "Stdout",
		2: "File",
		3: "Fluent",
		4: "CloudWatch",
		5: "AliYun",
		6: "Sys",
		7: "Hc",
	}
	CoreType_value = map[string]int32{
		"Unkown":     0,
		"Stdout":     1,
		"File":       2,
		"Fluent":     3,
		"CloudWatch": 4,
		"AliYun":     5,
		"Sys":        6,
		"Hc":         7,
	}
)

Enum value maps for CoreType.

View Source
var File_log_conf_proto protoreflect.FileDescriptor

Functions

func Create added in v0.0.36

func Create(c *Conf) (core.Logger, error)

Create instantiates a cores based on `discoveryDSN`.

func Debug

func Debug(a ...interface{})

Debug logs a message at debug level.

func Debugf

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

Debugf logs a message at debug level.

func Debugw

func Debugw(msg string, keyvals ...interface{})

Debugw logs a message at debug level.

func Error

func Error(a ...interface{})

Error logs a message at error level.

func ErrorPanic

func ErrorPanic(err interface{})

ErrorPanic logs a message at error level.

func ErrorStack

func ErrorStack(err error)

ErrorStack logs a message at error level.

func Errorf

func Errorf(format string, a ...interface{})

Errorf logs a message at error level.

func Errorw

func Errorw(msg string, keyvals ...interface{})

Errorw logs a message at error level.

func Fatal

func Fatal(a ...interface{})

Fatal logs a message at fatal level.

func Fatalf

func Fatalf(format string, a ...interface{})

Fatalf logs a message at fatal level.

func Fatalw

func Fatalw(msg string, keyvals ...interface{})

Fatalw logs a message at fatal level.

func GetCore

func GetCore() zapcore.Core

func Info

func Info(a ...interface{})

Info logs a message at info level.

func Infof

func Infof(format string, a ...interface{})

Infof logs a message at info level.

func Infow

func Infow(msg string, keyvals ...interface{})

Infow logs a message at info level.

func Init

func Init(c []*Conf) core.Logger

func MustCreate added in v0.0.36

func MustCreate(c *Conf) core.Logger

MustCreate instantiates a cores based on `discoveryDSN`.

func Register added in v0.0.36

func Register(name string, factory Factory)

Register registers one cores.

func SetLogger

func SetLogger(logger *ZapLogger)

SetLogger should be called before any other log call. And it is NOT THREAD SAFE.

func Warn

func Warn(a ...interface{})

Warn logs a message at warn level.

func Warnf

func Warnf(format string, a ...interface{})

Warnf logs a message at warnf level.

func Warnw

func Warnw(msg string, keyvals ...interface{})

Warnw logs a message at warnf level.

func WithCore added in v0.0.29

func WithCore(c zapcore.Core, kv ...interface{}) zapcore.Core

Types

type Conf

type Conf struct {
	Type         CoreType `protobuf:"varint,1,opt,name=type,proto3,enum=log.CoreType" json:"type,omitempty"`
	Level        int32    `protobuf:"varint,2,opt,name=level,proto3" json:"level,omitempty"`
	Path         string   `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"`
	Endpoint     string   `protobuf:"bytes,4,opt,name=endpoint,proto3" json:"endpoint,omitempty"`
	Key          string   `protobuf:"bytes,5,opt,name=key,proto3" json:"key,omitempty"`
	Secret       string   `protobuf:"bytes,6,opt,name=secret,proto3" json:"secret,omitempty"`
	Region       string   `protobuf:"bytes,7,opt,name=region,proto3" json:"region,omitempty"`
	Profile      string   `protobuf:"bytes,8,opt,name=profile,proto3" json:"profile,omitempty"`
	LogGroupName string   `protobuf:"bytes,9,opt,name=logGroupName,proto3" json:"logGroupName,omitempty"`
	// contains filtered or unexported fields
}

func (*Conf) Descriptor deprecated

func (*Conf) Descriptor() ([]byte, []int)

Deprecated: Use Conf.ProtoReflect.Descriptor instead.

func (*Conf) GetEndpoint added in v0.0.36

func (x *Conf) GetEndpoint() string

func (*Conf) GetKey added in v0.0.36

func (x *Conf) GetKey() string

func (*Conf) GetLevel added in v0.0.36

func (x *Conf) GetLevel() int32

func (*Conf) GetLogGroupName added in v0.0.36

func (x *Conf) GetLogGroupName() string

func (*Conf) GetPath added in v0.0.36

func (x *Conf) GetPath() string

func (*Conf) GetProfile added in v0.0.36

func (x *Conf) GetProfile() string

func (*Conf) GetRegion added in v0.0.36

func (x *Conf) GetRegion() string

func (*Conf) GetSecret added in v0.0.36

func (x *Conf) GetSecret() string

func (*Conf) GetType added in v0.0.36

func (x *Conf) GetType() CoreType

func (*Conf) ProtoMessage

func (*Conf) ProtoMessage()

func (*Conf) ProtoReflect

func (x *Conf) ProtoReflect() protoreflect.Message

func (*Conf) Reset

func (x *Conf) Reset()

func (*Conf) String

func (x *Conf) String() string

func (*Conf) Validate

func (m *Conf) Validate() error

Validate checks the field values on Conf with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*Conf) ValidateAll added in v0.0.8

func (m *Conf) ValidateAll() error

ValidateAll checks the field values on Conf with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in ConfMultiError, or nil if none found.

type ConfMultiError added in v0.0.8

type ConfMultiError []error

ConfMultiError is an error wrapping multiple validation errors returned by Conf.ValidateAll() if the designated constraints aren't met.

func (ConfMultiError) AllErrors added in v0.0.8

func (m ConfMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (ConfMultiError) Error added in v0.0.8

func (m ConfMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type ConfValidationError

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

ConfValidationError is the validation error returned by Conf.Validate if the designated constraints aren't met.

func (ConfValidationError) Cause

func (e ConfValidationError) Cause() error

Cause function returns cause value.

func (ConfValidationError) Error

func (e ConfValidationError) Error() string

Error satisfies the builtin error interface

func (ConfValidationError) ErrorName

func (e ConfValidationError) ErrorName() string

ErrorName returns error name.

func (ConfValidationError) Field

func (e ConfValidationError) Field() string

Field function returns field value.

func (ConfValidationError) Key

func (e ConfValidationError) Key() bool

Key function returns key value.

func (ConfValidationError) Reason

func (e ConfValidationError) Reason() string

Reason function returns reason value.

type CoreType added in v0.0.36

type CoreType int32
const (
	CoreType_Unkown     CoreType = 0
	CoreType_Stdout     CoreType = 1
	CoreType_File       CoreType = 2
	CoreType_Fluent     CoreType = 3
	CoreType_CloudWatch CoreType = 4
	CoreType_AliYun     CoreType = 5
	CoreType_Sys        CoreType = 6
	CoreType_Hc         CoreType = 7
)

func (CoreType) Descriptor added in v0.0.36

func (CoreType) Descriptor() protoreflect.EnumDescriptor

func (CoreType) Enum added in v0.0.36

func (x CoreType) Enum() *CoreType

func (CoreType) EnumDescriptor deprecated added in v0.0.36

func (CoreType) EnumDescriptor() ([]byte, []int)

Deprecated: Use CoreType.Descriptor instead.

func (CoreType) Number added in v0.0.36

func (x CoreType) Number() protoreflect.EnumNumber

func (CoreType) String added in v0.0.36

func (x CoreType) String() string

func (CoreType) Type added in v0.0.36

type Factory added in v0.0.36

type Factory func(c *Conf) (core.Logger, error)

type Registry added in v0.0.36

type Registry interface {
	Register(name string, factory Factory)
	Create(c *Conf) (core.Logger, error)
}

Registry is the interface for callers to get registered middleware.

func NewRegistry added in v0.0.36

func NewRegistry() Registry

NewRegistry returns a new middleware registry.

type ZapLogger

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

func GetLogger

func GetLogger() *ZapLogger

GetLogger returns global logger appliance as logger in current process.

func NewLogger

func NewLogger(core zapcore.Core, n int) *ZapLogger

func NewZapLogger

func NewZapLogger(core zapcore.Core, n int) *ZapLogger

func With

func With(kv ...interface{}) *ZapLogger

func (*ZapLogger) Debug

func (s *ZapLogger) Debug(a ...interface{})

Debug logs a message at debug level.

func (*ZapLogger) Debugf

func (s *ZapLogger) Debugf(format string, a ...interface{})

Debugf logs a message at debug level.

func (*ZapLogger) Debugw

func (s *ZapLogger) Debugw(msg string, keyvals ...interface{})

Debugw logs a message at debug level.

func (*ZapLogger) Error

func (s *ZapLogger) Error(a ...interface{})

Error logs a message at error level.

func (*ZapLogger) Errorf

func (s *ZapLogger) Errorf(format string, a ...interface{})

Errorf logs a message at error level.

func (*ZapLogger) Errorw

func (s *ZapLogger) Errorw(msg string, keyvals ...interface{})

Errorw logs a message at error level.

func (*ZapLogger) Fatal

func (s *ZapLogger) Fatal(a ...interface{})

Fatal logs a message at fatal level.

func (*ZapLogger) Fatalf

func (s *ZapLogger) Fatalf(format string, a ...interface{})

Fatalf logs a message at fatal level.

func (*ZapLogger) Fatalw

func (s *ZapLogger) Fatalw(msg string, keyvals ...interface{})

Fatalw logs a message at fatal level.

func (*ZapLogger) Info

func (s *ZapLogger) Info(a ...interface{})

Info logs a message at info level.

func (*ZapLogger) Infof

func (s *ZapLogger) Infof(format string, a ...interface{})

Infof logs a message at info level.

func (*ZapLogger) Infow

func (s *ZapLogger) Infow(msg string, keyvals ...interface{})

Infow logs a message at info level.

func (*ZapLogger) Log

func (s *ZapLogger) Log(level log.Level, keyvals ...interface{}) error

Log print the kv pairs log.

func (*ZapLogger) LogRoundTrip

func (s *ZapLogger) LogRoundTrip(
	req *http.Request,
	res *http.Response,
	err error,
	start time.Time,
	dur time.Duration,
) error

LogRoundTrip prints the information about request and response.

func (*ZapLogger) Printf

func (s *ZapLogger) Printf(format string, args ...interface{})

func (*ZapLogger) Println

func (s *ZapLogger) Println(a ...interface{})

func (*ZapLogger) RequestBodyEnabled

func (s *ZapLogger) RequestBodyEnabled() bool

RequestBodyEnabled makes the client pass request body to logger

func (*ZapLogger) ResponseBodyEnabled

func (s *ZapLogger) ResponseBodyEnabled() bool

ResponseBodyEnabled makes the client pass response body to logger

func (*ZapLogger) Warn

func (s *ZapLogger) Warn(a ...interface{})

Warn logs a message at warn level.

func (*ZapLogger) Warnf

func (s *ZapLogger) Warnf(format string, a ...interface{})

Warnf logs a message at warnf level.

func (*ZapLogger) Warnw

func (s *ZapLogger) Warnw(msg string, keyvals ...interface{})

Warnw logs a message at warnf level.

func (*ZapLogger) With added in v0.0.29

func (s *ZapLogger) With(kv ...interface{}) *ZapLogger

type ZapLoggerEx

type ZapLoggerEx struct {
	ZapLogger
}

func NewZapLoggerEx

func NewZapLoggerEx(core zapcore.Core) *ZapLoggerEx

func (*ZapLoggerEx) Error

func (s *ZapLoggerEx) Error(err error, msg string, keysAndValues ...interface{})

Error logs an error condition.

func (*ZapLoggerEx) Info

func (s *ZapLoggerEx) Info(msg string, keysAndValues ...interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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