Documentation ¶
Overview ¶
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. * *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *SOFTWARE.
Index ¶
- Constants
- Variables
- func GetLogger(ctx context.Context) *logrus.Entry
- func GetLoggerOrFallback(ctx context.Context, defaultValue string) *logrus.Entry
- func WithRotate(log *logrus.Logger, filedir string, redirect Log_Redirct, ...) error
- type CallerPrettyfierFunc
- type CompletedConfig
- type Config
- type ConfigOption
- type ConfigOptionFunc
- type EmptyConfigOption
- type EmptyRotateOption
- type HookHandler
- type Log
- func (*Log) Descriptor() ([]byte, []int)deprecated
- func (x *Log) GetEnableGoroutineId() bool
- func (x *Log) GetFilepath() string
- func (x *Log) GetFormatter() Log_Formatter
- func (x *Log) GetLevel() Log_Level
- func (x *Log) GetMaxAge() *duration.Duration
- func (x *Log) GetMaxCount() int64
- func (x *Log) GetRedirct() Log_Redirct
- func (x *Log) GetReportCaller() bool
- func (x *Log) GetRotateInterval() *duration.Duration
- func (x *Log) GetRotateSize() int64
- func (*Log) ProtoMessage()
- func (x *Log) ProtoReflect() protoreflect.Message
- func (x *Log) Reset()
- func (x *Log) String() string
- type Log_Formatter
- func (Log_Formatter) Descriptor() protoreflect.EnumDescriptor
- func (x Log_Formatter) Enum() *Log_Formatter
- func (Log_Formatter) EnumDescriptor() ([]byte, []int)deprecated
- func (x Log_Formatter) Number() protoreflect.EnumNumber
- func (x Log_Formatter) String() string
- func (Log_Formatter) Type() protoreflect.EnumType
- type Log_Level
- type Log_Redirct
- func (Log_Redirct) Descriptor() protoreflect.EnumDescriptor
- func (x Log_Redirct) Enum() *Log_Redirct
- func (Log_Redirct) EnumDescriptor() ([]byte, []int)deprecated
- func (x Log_Redirct) Number() protoreflect.EnumNumber
- func (x Log_Redirct) String() string
- func (Log_Redirct) Type() protoreflect.EnumType
- type Rotate
- type RotateOption
- func WithMaxAge(maxAge time.Duration) RotateOption
- func WithMaxCount(maxCount int64) RotateOption
- func WithPrefixName(prefixName string) RotateOption
- func WithRotateInterval(rotateInterval time.Duration) RotateOption
- func WithRotateSize(rotateSize int64) RotateOption
- func WithSuffixName(suffixName string) RotateOption
- type RotateOptionFunc
Constants ¶
const ( DefaultMaxAge = 72 * time.Hour DefaultMaxCount = 72 DefaultRotateInterval = time.Hour //100MB DefaultRotateSize = 104857600 )
Variables ¶
var ( Log_Level_name = map[int32]string{ 0: "panic", 1: "fatal", 2: "error", 3: "warn", 4: "info", 5: "debug", 6: "trace", } Log_Level_value = map[string]int32{ "panic": 0, "fatal": 1, "error": 2, "warn": 3, "info": 4, "debug": 5, "trace": 6, } )
Enum value maps for Log_Level.
var ( Log_Formatter_name = map[int32]string{ 0: "text", 1: "json", 2: "glog", } Log_Formatter_value = map[string]int32{ "text": 0, "json": 1, "glog": 2, } )
Enum value maps for Log_Formatter.
var ( Log_Redirct_name = map[int32]string{ 0: "stdout", 1: "file", } Log_Redirct_value = map[string]int32{ "stdout": 0, "file": 1, } )
Enum value maps for Log_Redirct.
var File_pkg_logs_log_proto protoreflect.FileDescriptor
Functions ¶
func GetLoggerOrFallback ¶ added in v0.0.81
func WithRotate ¶
func WithRotate(log *logrus.Logger, filedir string, redirect Log_Redirct, options ...RotateOption) error
Types ¶
type CallerPrettyfierFunc ¶
func GenShortCallPrettyfier ¶
func GenShortCallPrettyfier() CallerPrettyfierFunc
type CompletedConfig ¶
type CompletedConfig struct {
// contains filtered or unexported fields
}
type Config ¶
type Config struct { Proto Log Validator *validator.Validate // contains filtered or unexported fields }
func NewConfig ¶
func NewConfig(options ...ConfigOption) *Config
func (*Config) ApplyOptions ¶
func (o *Config) ApplyOptions(options ...ConfigOption) *Config
func (*Config) Complete ¶
func (c *Config) Complete() CompletedConfig
Complete set default ServerRunOptions.
type ConfigOption ¶
type ConfigOption interface {
// contains filtered or unexported methods
}
A ConfigOption sets options.
func WithViper ¶
func WithViper(v *viper.Viper) ConfigOption
type ConfigOptionFunc ¶
type ConfigOptionFunc func(*Config)
ConfigOptionFunc wraps a function that modifies Client into an implementation of the ConfigOption interface.
type EmptyConfigOption ¶
type EmptyConfigOption struct{}
EmptyConfigOption does not alter the configuration. It can be embedded in another structure to build custom options.
This API is EXPERIMENTAL.
type EmptyRotateOption ¶
type EmptyRotateOption struct{}
EmptyRotateOption does not alter the configuration. It can be embedded in another structure to build custom options.
This API is EXPERIMENTAL.
type HookHandler ¶
func (HookHandler) Levels ¶
func (h HookHandler) Levels() []logrus.Level
type Log ¶
type Log struct { Level Log_Level `protobuf:"varint,1,opt,name=level,proto3,enum=api.v1.viper.logs.Log_Level" json:"level,omitempty"` Formatter Log_Formatter `protobuf:"varint,2,opt,name=formatter,proto3,enum=api.v1.viper.logs.Log_Formatter" json:"formatter,omitempty"` Filepath string `protobuf:"bytes,3,opt,name=filepath,proto3" json:"filepath,omitempty"` MaxAge *duration.Duration `protobuf:"bytes,4,opt,name=max_age,json=maxAge,proto3" json:"max_age,omitempty"` MaxCount int64 `protobuf:"varint,5,opt,name=max_count,json=maxCount,proto3" json:"max_count,omitempty"` RotateInterval *duration.Duration `protobuf:"bytes,6,opt,name=rotate_interval,json=rotateInterval,proto3" json:"rotate_interval,omitempty"` RotateSize int64 `protobuf:"varint,7,opt,name=rotate_size,json=rotateSize,proto3" json:"rotate_size,omitempty"` ReportCaller bool `protobuf:"varint,8,opt,name=report_caller,json=reportCaller,proto3" json:"report_caller,omitempty"` EnableGoroutineId bool `protobuf:"varint,9,opt,name=enable_goroutine_id,json=enableGoroutineId,proto3" json:"enable_goroutine_id,omitempty"` Redirct Log_Redirct `protobuf:"varint,10,opt,name=redirct,proto3,enum=api.v1.viper.logs.Log_Redirct" json:"redirct,omitempty"` // contains filtered or unexported fields }
func (*Log) Descriptor
deprecated
func (*Log) GetEnableGoroutineId ¶ added in v0.0.73
func (*Log) GetFilepath ¶
func (*Log) GetFormatter ¶
func (x *Log) GetFormatter() Log_Formatter
func (*Log) GetMaxCount ¶
func (*Log) GetRedirct ¶ added in v0.0.86
func (x *Log) GetRedirct() Log_Redirct
func (*Log) GetReportCaller ¶
func (*Log) GetRotateInterval ¶
func (*Log) GetRotateSize ¶
func (*Log) ProtoMessage ¶
func (*Log) ProtoMessage()
func (*Log) ProtoReflect ¶
func (x *Log) ProtoReflect() protoreflect.Message
type Log_Formatter ¶
type Log_Formatter int32
const ( Log_text Log_Formatter = 0 Log_json Log_Formatter = 1 Log_glog Log_Formatter = 2 )
func (Log_Formatter) Descriptor ¶
func (Log_Formatter) Descriptor() protoreflect.EnumDescriptor
func (Log_Formatter) Enum ¶
func (x Log_Formatter) Enum() *Log_Formatter
func (Log_Formatter) EnumDescriptor
deprecated
func (Log_Formatter) EnumDescriptor() ([]byte, []int)
Deprecated: Use Log_Formatter.Descriptor instead.
func (Log_Formatter) Number ¶
func (x Log_Formatter) Number() protoreflect.EnumNumber
func (Log_Formatter) String ¶
func (x Log_Formatter) String() string
func (Log_Formatter) Type ¶
func (Log_Formatter) Type() protoreflect.EnumType
type Log_Level ¶
type Log_Level int32
func (Log_Level) Descriptor ¶
func (Log_Level) Descriptor() protoreflect.EnumDescriptor
func (Log_Level) EnumDescriptor
deprecated
func (Log_Level) Number ¶
func (x Log_Level) Number() protoreflect.EnumNumber
func (Log_Level) Type ¶
func (Log_Level) Type() protoreflect.EnumType
type Log_Redirct ¶ added in v0.0.86
type Log_Redirct int32
const ( Log_stdout Log_Redirct = 0 Log_file Log_Redirct = 1 )
func (Log_Redirct) Descriptor ¶ added in v0.0.86
func (Log_Redirct) Descriptor() protoreflect.EnumDescriptor
func (Log_Redirct) Enum ¶ added in v0.0.86
func (x Log_Redirct) Enum() *Log_Redirct
func (Log_Redirct) EnumDescriptor
deprecated
added in
v0.0.86
func (Log_Redirct) EnumDescriptor() ([]byte, []int)
Deprecated: Use Log_Redirct.Descriptor instead.
func (Log_Redirct) Number ¶ added in v0.0.86
func (x Log_Redirct) Number() protoreflect.EnumNumber
func (Log_Redirct) String ¶ added in v0.0.86
func (x Log_Redirct) String() string
func (Log_Redirct) Type ¶ added in v0.0.86
func (Log_Redirct) Type() protoreflect.EnumType
type Rotate ¶
type Rotate struct {
// contains filtered or unexported fields
}
func (*Rotate) ApplyOptions ¶
func (o *Rotate) ApplyOptions(options ...RotateOption) *Rotate
type RotateOption ¶
type RotateOption interface {
// contains filtered or unexported methods
}
A RotateOption sets options.
func WithMaxAge ¶
func WithMaxAge(maxAge time.Duration) RotateOption
func WithMaxCount ¶
func WithMaxCount(maxCount int64) RotateOption
func WithPrefixName ¶
func WithPrefixName(prefixName string) RotateOption
func WithRotateInterval ¶
func WithRotateInterval(rotateInterval time.Duration) RotateOption
func WithRotateSize ¶
func WithRotateSize(rotateSize int64) RotateOption
func WithSuffixName ¶
func WithSuffixName(suffixName string) RotateOption
type RotateOptionFunc ¶
type RotateOptionFunc func(*Rotate)
RotateOptionFunc wraps a function that modifies Client into an implementation of the RotateOption interface.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software.
|
*Copyright (c) 2022, kaydxh * *Permission is hereby granted, free of charge, to any person obtaining a copy *of this software and associated documentation files (the "Software"), to deal *in the Software without restriction, including without limitation the rights *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *copies of the Software, and to permit persons to whom the Software is *furnished to do so, subject to the following conditions: * *The above copyright notice and this permission notice shall be included in all *copies or substantial portions of the Software. |