rkmidlog

package
v2.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package rkmidlog provide options

Index

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

func WithEntryNameAndType(entryName, entryType string) Option

WithEntryNameAndType provide entry name and entry type.

func WithEventEncoding

func WithEventEncoding(ec string) Option

WithEventEncoding provide ZapLoggerEncodingType. Console or Json is supported.

func WithEventEntry

func WithEventEntry(eventEntry *rkentry.EventEntry) Option

WithEventEntry provide rkentry.EventEntry.

func WithEventOutputPaths

func WithEventOutputPaths(path ...string) Option

WithEventOutputPaths provide EventLogger Output Path. Multiple output path could be supported including stdout.

func WithLoggerEncoding

func WithLoggerEncoding(ec string) Option

WithLoggerEncoding provide ZapLoggerEncodingType. json or console is supported.

func WithLoggerEntry

func WithLoggerEntry(loggerEntry *rkentry.LoggerEntry) Option

WithLoggerEntry provide rkentry.LoggerEntry.

func WithLoggerOutputPaths

func WithLoggerOutputPaths(path ...string) Option

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

func WithPathToIgnore(paths ...string) Option

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

Jump to

Keyboard shortcuts

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