echotool

package module
v1.0.40 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 33 Imported by: 0

README

echotool

There are some useful tools.

Documentation

Index

Constants

View Source
const (
	BValidator = 1 << iota
	BHeader
	BParam
	BFormQuery
	BFormBody
	BFormQueryBody
	BFormMultipart
	BJSONBody
	BXMLBody
	BProtobufBody
	BMsgpackBody
	BYAMLBody
	BEnv
)
View Source
const (
	CodeOKZero         = 0
	CodeOK             = 20000
	CodeCreated        = 20100
	CodePartialContent = 20600

	CodeMultipleChoices   = 30000
	CodeMovedPermanently  = 30100
	CodeFound             = 30200
	CodeSeeOther          = 30300
	CodeNotModified       = 30400
	CodeUseProxy          = 30500
	CodeTemporaryRedirect = 30700
	CodePermanentRedirect = 30800

	CodeBadRequest      = 40000
	CodeUnauthorized    = 40100
	CodeForbidden       = 40300
	CodeNotFound        = 40400
	CodeTooManyRequests = 42900
	CodeValidateErr     = 45000

	CodeInternalErr        = 50000
	CodeServiceUnavailable = 50300
	CodeParseDataErr       = 50013
	CodeMySQLErr           = 50014
	CodePostgreSQLErr      = 50015
	CodeRedisErr           = 50016
	CodeClickHouseErr      = 50017
	CodeMongoDBErr         = 50018
	CodeElasticsearchErr   = 50019
	CodeNSQErr             = 50030
	CodeKafkaErr           = 50031
	CodeRocketMQErr        = 50032
	CodeBindErr            = 50040
	CodeEncodeErr          = 50041
	CodeDownstreamErr      = 50099
)
View Source
const (
	EnvDev     = "dev"
	EnvTest    = "test"
	EnvProduct = "prod"
)
View Source
const (
	KeyRequestID = "x-request-id"
)
View Source
const (
	UnknownStatus = 999
)

Variables

This section is empty.

Functions

func AbortWithCodeErr

func AbortWithCodeErr(c echo.Context, code int, err error)

func AcquireBuffer

func AcquireBuffer() *bytes.Buffer

func AutoIncrID added in v1.0.7

func AutoIncrID(id *int64)

func Bind

func Bind(c echo.Context, v interface{}, flag int) (err error)

func BindEnv added in v1.0.8

func BindEnv(c echo.Context, v interface{}) error

BindEnv needs tag "env" in fields of v.

func BindHeader

func BindHeader(c echo.Context, v interface{}) error

BindHeader needs tag "header" in fields of v. The value of tag "header" is automatically converted to the canonical format.

func BindParam

func BindParam(c echo.Context, v interface{}) error

BindParam needs tag "param" in fields of v.

func CodeMsg

func CodeMsg(code int) string

func CtxDebug added in v1.0.1

func CtxDebug(ec *Context, format string, args ...interface{})

func CtxDebugKV added in v1.0.3

func CtxDebugKV(ec *Context, msg string, fields ...zap.Field)

func CtxError added in v1.0.1

func CtxError(ec *Context, format string, args ...interface{})

func CtxErrorKV added in v1.0.3

func CtxErrorKV(ec *Context, msg string, fields ...zap.Field)

func CtxFatal added in v1.0.1

func CtxFatal(ec *Context, format string, args ...interface{})

CtxFatal logs a message, then calls os.Exit.

func CtxFatalKV added in v1.0.3

func CtxFatalKV(ec *Context, msg string, fields ...zap.Field)

CtxFatalKV logs a message, then calls os.Exit.

func CtxInfo added in v1.0.1

func CtxInfo(ec *Context, format string, args ...interface{})

func CtxInfoKV added in v1.0.3

func CtxInfoKV(ec *Context, msg string, fields ...zap.Field)

func CtxPanic added in v1.0.1

func CtxPanic(ec *Context, format string, args ...interface{})

CtxPanic logs a message, then panics.

func CtxPanicKV added in v1.0.3

func CtxPanicKV(ec *Context, msg string, fields ...zap.Field)

CtxPanicKV logs a message, then panics.

func CtxPrint added in v1.0.38

func CtxPrint(ec *Context, level zapcore.Level, format string, args ...interface{})

func CtxPrintKV added in v1.0.38

func CtxPrintKV(ec *Context, level zapcore.Level, msg string, fields ...zap.Field)

func CtxWarn added in v1.0.1

func CtxWarn(ec *Context, format string, args ...interface{})

func CtxWarnKV added in v1.0.3

func CtxWarnKV(ec *Context, msg string, fields ...zap.Field)

func Debug added in v1.0.2

func Debug(format string, args ...interface{})

func DebugKV added in v1.0.3

func DebugKV(msg string, fields ...zap.Field)

func DefaultCORS added in v1.0.32

func DefaultCORS() echo.MiddlewareFunc

func EncodeJSON

func EncodeJSON(v interface{}) (*bytes.Buffer, error)

EncodeJSON needs tag "json" in fields of v. Note: ReleaseBuffer needs to be called after EncodeJSON is called successfully.

func EncodeValues

func EncodeValues(v interface{}) (url.Values, error)

EncodeValues needs tag "url" in fields of v.

func Env added in v1.0.36

func Env() (env string)

func EnvBool added in v1.0.8

func EnvBool(c echo.Context, key string) (bool, error)

func EnvInt64 added in v1.0.8

func EnvInt64(c echo.Context, key string) (int64, error)

func EnvString added in v1.0.8

func EnvString(c echo.Context, key string) (string, error)

func EnvUint64 added in v1.0.8

func EnvUint64(c echo.Context, key string) (uint64, error)

func Error added in v1.0.2

func Error(format string, args ...interface{})

func ErrorKV added in v1.0.3

func ErrorKV(msg string, fields ...zap.Field)

func FasterJSONReflectedEncoder added in v1.0.3

func FasterJSONReflectedEncoder(w io.Writer) zapcore.ReflectedEncoder

func Fatal added in v1.0.2

func Fatal(format string, args ...interface{})

Fatal logs a message, then calls os.Exit.

func FatalKV added in v1.0.3

func FatalKV(msg string, fields ...zap.Field)

FatalKV logs a message, then calls os.Exit.

func FinishWithCodeData

func FinishWithCodeData(c echo.Context, code int, data interface{})

func FlushLog added in v1.0.1

func FlushLog() error

FlushLog flushes any buffered log entries.

func ForceRegisterBinder added in v1.0.13

func ForceRegisterBinder(flag int, fn func(echo.Context, interface{}) error)

func ForceRegisterCode

func ForceRegisterCode(code int, msg string, status int)

ForceRegisterCode will force to cover codeMsg map and httpStatus map.

func FormBindBody

func FormBindBody(c echo.Context, v interface{}) error

FormBindBody needs tag "form" in fields of v.

func FormBindMultipart added in v1.0.26

func FormBindMultipart(c echo.Context, v interface{}) error

FormBindMultipart needs tag "form" in fields of v.

func FormBindQuery

func FormBindQuery(c echo.Context, v interface{}) error

FormBindQuery needs tag "form" in fields of v.

func FormBindQueryBody

func FormBindQueryBody(c echo.Context, v interface{}) error

FormBindQueryBody needs tag "form" in fields of v.

func FormBool

func FormBool(c echo.Context, key string) (bool, error)

func FormInt64

func FormInt64(c echo.Context, key string) (int64, error)

func FormString

func FormString(c echo.Context, key string) (string, error)

func FormUint64

func FormUint64(c echo.Context, key string) (uint64, error)

func GetConfDir added in v1.0.36

func GetConfDir() string

func GetHandlerName added in v1.0.17

func GetHandlerName(f HandlerFunc) string

func GetHostname added in v1.0.1

func GetHostname() (host string)

func GetRequestHost

func GetRequestHost(req *http.Request) (host string)

func GetRequestID

func GetRequestID(c echo.Context) string

func GetUUID

func GetUUID(c echo.Context) (u string)

func HTTPStatus

func HTTPStatus(code int) int

func HeaderBool

func HeaderBool(c echo.Context, key string) (bool, error)

func HeaderInt64

func HeaderInt64(c echo.Context, key string) (int64, error)

func HeaderString

func HeaderString(c echo.Context, key string) (string, error)

func HeaderUint64

func HeaderUint64(c echo.Context, key string) (uint64, error)

func Info added in v1.0.2

func Info(format string, args ...interface{})

func InfoKV added in v1.0.3

func InfoKV(msg string, fields ...zap.Field)

func IsEchotoolError

func IsEchotoolError(err error) bool

func IsEmptyError

func IsEmptyError(err error) bool

func IsProduct added in v1.0.36

func IsProduct() bool

func IsTest added in v1.0.36

func IsTest() bool

func JSONBindBody

func JSONBindBody(c echo.Context, v interface{}) error

JSONBindBody needs tag "json" in fields of v.

func MsgpackBindBody

func MsgpackBindBody(c echo.Context, v interface{}) error

MsgpackBindBody needs tag "msgpack" in fields of v.

func MustBind

func MustBind(c echo.Context, v interface{}, flag int, cbs ...CallbackFunc)

func MustBindEnv added in v1.0.8

func MustBindEnv(c echo.Context, v interface{}, cbs ...CallbackFunc)

func MustBindHeader

func MustBindHeader(c echo.Context, v interface{}, cbs ...CallbackFunc)

func MustBindParam

func MustBindParam(c echo.Context, v interface{}, cbs ...CallbackFunc)

func MustDo

func MustDo(run RunFunc, codes ...int) interface{}

func MustDoCallback

func MustDoCallback(run RunFunc, code int, cbs ...CallbackFunc) interface{}

MustDoCallback will call cbs if and only if run has error.

func MustEncodeJSON

func MustEncodeJSON(v interface{}, cbs ...CallbackFunc) *bytes.Buffer

MustEncodeJSON needs tag "json" in fields of v. Note: ReleaseBuffer needs to be called after MustEncodeJSON is called successfully.

func MustEncodeValues

func MustEncodeValues(v interface{}, cbs ...CallbackFunc) url.Values

func MustEnvBool added in v1.0.8

func MustEnvBool(c echo.Context, key string, cbs ...CallbackFunc) bool

func MustEnvInt64 added in v1.0.8

func MustEnvInt64(c echo.Context, key string, cbs ...CallbackFunc) int64

func MustEnvString added in v1.0.8

func MustEnvString(c echo.Context, key string, cbs ...CallbackFunc) string

func MustEnvUint64 added in v1.0.8

func MustEnvUint64(c echo.Context, key string, cbs ...CallbackFunc) uint64

func MustFormBindBody

func MustFormBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)

func MustFormBindMultipart added in v1.0.26

func MustFormBindMultipart(c echo.Context, v interface{}, cbs ...CallbackFunc)

func MustFormBindQuery

func MustFormBindQuery(c echo.Context, v interface{}, cbs ...CallbackFunc)

func MustFormBindQueryBody

func MustFormBindQueryBody(c echo.Context, v interface{}, cbs ...CallbackFunc)

func MustFormBool

func MustFormBool(c echo.Context, key string, cbs ...CallbackFunc) bool

func MustFormInt64

func MustFormInt64(c echo.Context, key string, cbs ...CallbackFunc) int64

func MustFormString

func MustFormString(c echo.Context, key string, cbs ...CallbackFunc) string

func MustFormUint64

func MustFormUint64(c echo.Context, key string, cbs ...CallbackFunc) uint64

func MustHeaderBool

func MustHeaderBool(c echo.Context, key string, cbs ...CallbackFunc) bool

func MustHeaderInt64

func MustHeaderInt64(c echo.Context, key string, cbs ...CallbackFunc) int64

func MustHeaderString

func MustHeaderString(c echo.Context, key string, cbs ...CallbackFunc) string

func MustHeaderUInt64

func MustHeaderUInt64(c echo.Context, key string, cbs ...CallbackFunc) uint64

func MustJSONBindBody

func MustJSONBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)

func MustMsgpackBindBody

func MustMsgpackBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)

func MustParamBool

func MustParamBool(c echo.Context, key string, cbs ...CallbackFunc) bool

func MustParamInt64

func MustParamInt64(c echo.Context, key string, cbs ...CallbackFunc) int64

func MustParamString

func MustParamString(c echo.Context, key string, cbs ...CallbackFunc) string

func MustParamUInt64

func MustParamUInt64(c echo.Context, key string, cbs ...CallbackFunc) uint64

func MustPostFormBool

func MustPostFormBool(c echo.Context, key string, cbs ...CallbackFunc) bool

func MustPostFormInt64

func MustPostFormInt64(c echo.Context, key string, cbs ...CallbackFunc) int64

func MustPostFormString

func MustPostFormString(c echo.Context, key string, cbs ...CallbackFunc) string

func MustPostFormUInt64

func MustPostFormUInt64(c echo.Context, key string, cbs ...CallbackFunc) uint64

func MustProtobufBindBody

func MustProtobufBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)

func MustQueryBool

func MustQueryBool(c echo.Context, key string, cbs ...CallbackFunc) bool

func MustQueryInt64

func MustQueryInt64(c echo.Context, key string, cbs ...CallbackFunc) int64

func MustQueryString

func MustQueryString(c echo.Context, key string, cbs ...CallbackFunc) string

func MustQueryUInt64

func MustQueryUInt64(c echo.Context, key string, cbs ...CallbackFunc) uint64

func MustValidate

func MustValidate(v interface{}, cbs ...CallbackFunc)

func MustXMLBindBody

func MustXMLBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)

func MustYAMLBindBody

func MustYAMLBindBody(c echo.Context, v interface{}, cbs ...CallbackFunc)

func New

func New(c echo.Context, v interface{}) *proxy

func NewDefaultEcho added in v1.0.3

func NewDefaultEcho() *echo.Echo

func NewDefaultEncodeConfig added in v1.0.4

func NewDefaultEncodeConfig() zapcore.EncoderConfig

func NewDefaultGORMConfig added in v1.0.7

func NewDefaultGORMConfig(isCached bool) *gorm.Config

NewDefaultGORMConfig returns a default config with logger. Note that you should set PrepareStmt to false when using clickhouse.

func NewDefaultLogger added in v1.0.1

func NewDefaultLogger() *zap.SugaredLogger

func NewRotateLogger added in v1.0.4

func NewRotateLogger(opts ...RotateConfigOption) (*zap.SugaredLogger, error)

func Panic added in v1.0.2

func Panic(format string, args ...interface{})

Panic logs a message, then panics.

func PanicKV added in v1.0.3

func PanicKV(msg string, fields ...zap.Field)

PanicKV logs a message, then panics.

func ParamBool

func ParamBool(c echo.Context, key string) (bool, error)

func ParamInt64

func ParamInt64(c echo.Context, key string) (int64, error)

func ParamString

func ParamString(c echo.Context, key string) (string, error)

func ParamUint64

func ParamUint64(c echo.Context, key string) (uint64, error)

func ParseByEnv added in v1.0.36

func ParseByEnv(suffix string) string

func ParseByReg added in v1.0.36

func ParseByReg(suffix string) string

func ParseByTag added in v1.0.36

func ParseByTag(suffix string) string

func PostFormBool

func PostFormBool(c echo.Context, key string) (bool, error)

func PostFormInt64

func PostFormInt64(c echo.Context, key string) (int64, error)

func PostFormString

func PostFormString(c echo.Context, key string) (string, error)

func PostFormUint64

func PostFormUint64(c echo.Context, key string) (uint64, error)

func Print added in v1.0.38

func Print(level zapcore.Level, format string, args ...interface{})

func PrintKV added in v1.0.38

func PrintKV(level zapcore.Level, msg string, fields ...zap.Field)

func ProtobufBindBody

func ProtobufBindBody(c echo.Context, v interface{}) error

ProtobufBindBody needs tag "protobuf" in fields of v.

func QueryBool

func QueryBool(c echo.Context, key string) (bool, error)

func QueryInt64

func QueryInt64(c echo.Context, key string) (int64, error)

func QueryString

func QueryString(c echo.Context, key string) (string, error)

func QueryUint64

func QueryUint64(c echo.Context, key string) (uint64, error)

func Reg added in v1.0.36

func Reg() string

func RegisterBinder added in v1.0.13

func RegisterBinder(flag int, fn func(echo.Context, interface{}) error) bool

func RegisterCode

func RegisterCode(code int, msg string, status int) bool

RegisterCode will not cover code and status which exists.

func ReleaseBuffer

func ReleaseBuffer(buffer *bytes.Buffer)

func ReleaseEchotoolError

func ReleaseEchotoolError(e *EchotoolError)

func SetLogger added in v1.0.1

func SetLogger(l *zap.SugaredLogger)

func SetLoggerWithFinalizer added in v1.0.40

func SetLoggerWithFinalizer(l *zap.SugaredLogger)

func SetRequestID

func SetRequestID(f func(c echo.Context) string) echo.MiddlewareFunc

func Tag added in v1.0.36

func Tag() string

func UnsafeCORS added in v1.0.32

func UnsafeCORS() echo.MiddlewareFunc

func Validate

func Validate(v interface{}) error

Validate needs tag "valid" in fields of v.

func Warn added in v1.0.2

func Warn(format string, args ...interface{})

func WarnKV added in v1.0.3

func WarnKV(msg string, fields ...zap.Field)

func XMLBindBody

func XMLBindBody(c echo.Context, v interface{}) error

XMLBindBody needs tag "xml" in fields of v.

func YAMLBindBody

func YAMLBindBody(c echo.Context, v interface{}) error

YAMLBindBody needs tag "yaml" in fields of v.

Types

type CallbackFunc

type CallbackFunc func(error)

type CommonResponse

type CommonResponse struct {
	RequestID string      `json:"request_id,omitempty"`
	Code      int         `json:"code"`
	Message   string      `json:"message"`
	Data      interface{} `json:"data,omitempty"`
}

func RespError

func RespError(id string, code int, err error) *CommonResponse

func RespOK

func RespOK(id string, code int, data interface{}) *CommonResponse

type Context

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

func (*Context) Abort

func (ec *Context) Abort(code int, err error)

func (*Context) Clone added in v1.0.39

func (ec *Context) Clone() *Context

func (*Context) Deadline added in v1.0.6

func (ec *Context) Deadline() (deadline time.Time, ok bool)

func (*Context) Done added in v1.0.6

func (ec *Context) Done() <-chan struct{}

func (*Context) Err added in v1.0.6

func (ec *Context) Err() error

func (*Context) Finish

func (ec *Context) Finish(code int, data interface{})

func (*Context) GetCode

func (ec *Context) GetCode() int

func (*Context) GetCustomValue added in v1.0.1

func (ec *Context) GetCustomValue(key string) (value string, exists bool)

func (*Context) GetCustomValues added in v1.0.1

func (ec *Context) GetCustomValues() map[string]string

func (*Context) GetData

func (ec *Context) GetData() interface{}

func (*Context) GetError

func (ec *Context) GetError() error

func (*Context) GetHandlerName added in v1.0.17

func (ec *Context) GetHandlerName() string

func (*Context) GetNamedValue added in v1.0.1

func (ec *Context) GetNamedValue() string

func (*Context) GetStartTime added in v1.0.20

func (ec *Context) GetStartTime() time.Time

func (*Context) IsOK

func (ec *Context) IsOK() bool

func (*Context) Redirect added in v1.0.30

func (ec *Context) Redirect(code int, url string)

func (*Context) SetCustomValue added in v1.0.1

func (ec *Context) SetCustomValue(key, value string)

func (*Context) SetNamedValue added in v1.0.1

func (ec *Context) SetNamedValue(value string)

func (*Context) String

func (ec *Context) String() string

func (*Context) Value added in v1.0.6

func (ec *Context) Value(key interface{}) interface{}

type EchotoolError

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

func AcquireEchotoolError

func AcquireEchotoolError(code int, err error) (e *EchotoolError)

func (EchotoolError) Error

func (e EchotoolError) Error() string

func (EchotoolError) GetCode

func (e EchotoolError) GetCode() int

func (EchotoolError) GetError

func (e EchotoolError) GetError() error

type EmptyError

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

func NewEmptyError

func NewEmptyError(kind Kind, key string) *EmptyError

func NewEnvEmptyError added in v1.0.8

func NewEnvEmptyError(key string) *EmptyError

func NewFormEmptyError

func NewFormEmptyError(key string) *EmptyError

func NewHeaderEmptyError

func NewHeaderEmptyError(key string) *EmptyError

func NewParamEmptyError

func NewParamEmptyError(key string) *EmptyError

func NewPostFormEmptyError

func NewPostFormEmptyError(key string) *EmptyError

func NewQueryEmptyError

func NewQueryEmptyError(key string) *EmptyError

func (EmptyError) Error

func (e EmptyError) Error() string

type Engine

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

func NewDefaultEngine added in v1.0.3

func NewDefaultEngine(opts ...Option) *Engine

func NewEngine

func NewEngine(opts ...Option) *Engine

func (*Engine) EchoHandler

func (e *Engine) EchoHandler(handlers ...HandlerFunc) echo.HandlerFunc

func (*Engine) Use

func (e *Engine) Use(middlewares ...HandlerFunc) *Engine

type FileInfo added in v1.0.28

type FileInfo struct {
	Name    string
	Content []byte
}

func MustFormFile added in v1.0.23

func MustFormFile(c echo.Context, key string, cbs ...CallbackFunc) *FileInfo

type GORMLogger added in v1.0.6

type GORMLogger struct {
	Prefix         string
	SlowTime       time.Duration
	IgnoreNoRecord bool
}

func NewDefaultGORMLogger added in v1.0.6

func NewDefaultGORMLogger() *GORMLogger

func (*GORMLogger) Error added in v1.0.6

func (l *GORMLogger) Error(ctx context.Context, format string, args ...interface{})

func (*GORMLogger) Info added in v1.0.6

func (l *GORMLogger) Info(ctx context.Context, format string, args ...interface{})

func (*GORMLogger) LogMode added in v1.0.6

func (l *GORMLogger) LogMode(level gl.LogLevel) gl.Interface

func (*GORMLogger) Trace added in v1.0.6

func (l *GORMLogger) Trace(ctx context.Context, begin time.Time, f func() (string, int64), err error)

func (*GORMLogger) Warn added in v1.0.6

func (l *GORMLogger) Warn(ctx context.Context, format string, args ...interface{})

type HandlerFunc

type HandlerFunc func(echo.Context, *Context)

func AddNotice added in v1.0.1

func AddNotice(key, value string) HandlerFunc

AddNotice adds kv pair to log for troubleshooting problems and so on.

func AddTraceID added in v1.0.1

func AddTraceID(f func(c echo.Context) string) HandlerFunc

AddTraceID adds trace id to log for troubleshooting problems and so on.

func GetCommonAborter

func GetCommonAborter() HandlerFunc

func GetCommonFinisher

func GetCommonFinisher() HandlerFunc

func PrintRequest added in v1.0.5

func PrintRequest() HandlerFunc

type HandlerFuncsChain

type HandlerFuncsChain []HandlerFunc

type Kind

type Kind int
const (
	KindHeader Kind = iota
	KindParam
	KindQuery
	KindPostForm
	KindForm
	KindEnv
)

func (Kind) String

func (k Kind) String() string

type Option

type Option func(*Engine)

func WithAborter

func WithAborter(aborter HandlerFunc) Option

func WithFinisher

func WithFinisher(finisher HandlerFunc) Option

type RedisLogger added in v1.0.38

type RedisLogger struct {
	Level zapcore.Level
}

func NewRedisLogger added in v1.0.38

func NewRedisLogger(level string) *RedisLogger

func (*RedisLogger) DialHook added in v1.0.38

func (l *RedisLogger) DialHook(next redis.DialHook) redis.DialHook

func (*RedisLogger) ProcessHook added in v1.0.38

func (l *RedisLogger) ProcessHook(next redis.ProcessHook) redis.ProcessHook

func (*RedisLogger) ProcessPipelineHook added in v1.0.38

func (l *RedisLogger) ProcessPipelineHook(next redis.ProcessPipelineHook) redis.ProcessPipelineHook

type RotateConfig added in v1.0.4

type RotateConfig struct {
	EncoderConfig zapcore.EncoderConfig
	Paths         []string
	Suffix        string
	Level         zapcore.Level
	RotateTime    time.Duration
	TTL           time.Duration
}

RotateConfig is the config for rotating logs. The format of suffix refers to https://github.com/lestrrat-go/strftime.

type RotateConfigOption added in v1.0.4

type RotateConfigOption func(*RotateConfig)

func WithEncoderConfig added in v1.0.4

func WithEncoderConfig(cfg zapcore.EncoderConfig) RotateConfigOption

func WithLevel added in v1.0.4

func WithLevel(level zapcore.Level) RotateConfigOption

func WithPaths added in v1.0.4

func WithPaths(paths []string) RotateConfigOption

func WithRotateTime added in v1.0.4

func WithRotateTime(t time.Duration) RotateConfigOption

func WithSuffix added in v1.0.4

func WithSuffix(suffix string) RotateConfigOption

func WithTTL added in v1.0.4

func WithTTL(ttl time.Duration) RotateConfigOption

type RunFunc

type RunFunc func() (interface{}, error)

Jump to

Keyboard shortcuts

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