Documentation ¶
Overview ¶
Package rkmidlog provide options
Index ¶
- type AfterCtx
- type BeforeCtx
- type BootConfig
- type Option
- func ToOptions(config *BootConfig, entryName, entryType string, ...) []Option
- func WithEntryNameAndType(entryName, entryType string) Option
- func WithEventEncoding(ec string) Option
- func WithEventEntry(eventEntry *rkentry.EventEntry) Option
- func WithEventOutputPaths(path ...string) Option
- func WithLoggerEncoding(ec string) Option
- func WithLoggerEntry(loggerEntry *rkentry.LoggerEntry) Option
- func WithLoggerOutputPaths(path ...string) Option
- func WithMockOptionSet(mock OptionSetInterface) Option
- func WithPathToIgnore(paths ...string) Option
- type OptionSetInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AfterCtx ¶
type AfterCtx struct { Input struct { RequestId string TraceId string ResCode string } Output struct{} }
AfterCtx context for After() function
func NewAfterCtx ¶
func NewAfterCtx() *AfterCtx
NewAfterCtx create new AfterCtx with fields initialized
type BeforeCtx ¶
type BeforeCtx struct { Input struct { UrlPath string RemoteAddr string Method string RawQuery string Protocol string UserAgent string Fields []zap.Field } Output struct { Event rkquery.Event Logger *zap.Logger } }
BeforeCtx context for Before() function
func NewBeforeCtx ¶
func NewBeforeCtx() *BeforeCtx
NewBeforeCtx create new BeforeCtx with fields initialized
type BootConfig ¶
type BootConfig struct { Enabled bool `yaml:"enabled" json:"enabled"` LoggerEncoding string `yaml:"loggerEncoding" json:"loggerEncoding"` LoggerOutputPaths []string `yaml:"loggerOutputPaths" json:"loggerOutputPaths"` EventEncoding string `yaml:"eventEncoding" json:"eventEncoding"` EventOutputPaths []string `yaml:"eventOutputPaths" json:"eventOutputPaths"` Ignore []string `yaml:"ignore" json:"ignore"` }
BootConfig for YAML
type Option ¶
type Option func(*optionSet)
Option
func ToOptions ¶
func ToOptions(config *BootConfig, entryName, entryType string, loggerEntry *rkentry.LoggerEntry, eventEntry *rkentry.EventEntry) []Option
ToOptions convert BootConfig into Option list
func WithEntryNameAndType ¶
WithEntryNameAndType provide entry name and entry type.
func WithEventEncoding ¶
WithEventEncoding provide ZapLoggerEncodingType. Console or Json is supported.
func WithEventEntry ¶
func WithEventEntry(eventEntry *rkentry.EventEntry) Option
WithEventEntry provide rkentry.EventEntry.
func WithEventOutputPaths ¶
WithEventOutputPaths provide EventLogger Output Path. Multiple output path could be supported including stdout.
func WithLoggerEncoding ¶
WithLoggerEncoding provide ZapLoggerEncodingType. json or console is supported.
func WithLoggerEntry ¶
func WithLoggerEntry(loggerEntry *rkentry.LoggerEntry) Option
WithLoggerEntry provide rkentry.LoggerEntry.
func WithLoggerOutputPaths ¶
WithLoggerOutputPaths provide ZapLogger Output Path. Multiple output path could be supported including stdout.
func WithMockOptionSet ¶
func WithMockOptionSet(mock OptionSetInterface) Option
WithMockOptionSet provide mock OptionSetInterface
func WithPathToIgnore ¶
WithPathToIgnore provide paths prefix that will ignore.
type OptionSetInterface ¶
type OptionSetInterface interface { GetEntryName() string GetEntryType() string BeforeCtx(*http.Request) *BeforeCtx Before(*BeforeCtx) AfterCtx(reqId, traceId, resCode string) *AfterCtx After(before *BeforeCtx, after *AfterCtx) ShouldIgnore(string) bool }
OptionSetInterface mainly for testing purpose
func NewOptionSet ¶
func NewOptionSet(opts ...Option) OptionSetInterface
NewOptionSet Create new optionSet with options.
func NewOptionSetMock ¶
func NewOptionSetMock(before *BeforeCtx, after *AfterCtx) OptionSetInterface
NewOptionSetMock for testing purpose