utils

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: Apache-2.0 Imports: 15 Imported by: 14

Documentation

Index

Constants

View Source
const Defaultconfig = `` /* 270-byte string literal not displayed */

Variables

View Source
var (
	Logger = &logrus.Logger{
		Out: os.Stdout,
		Formatter: &logrus.TextFormatter{
			TimestampFormat: timestampFormat,
		},
		Hooks: make(logrus.LevelHooks),
		Level: logrus.InfoLevel,
	}
)

Functions

func CheckErrorValues

func CheckErrorValues(refvs []reflect.Value) (err error)

func CleanComments

func CleanComments(data []byte) (out []byte, err error)

CleanComments used for remove non-standard json comments. Supported comment formats ^\s*# and ^\s*//

func FormatWithEnv added in v0.2.0

func FormatWithEnv(text string) (result string)

FormatWithEnv format string with environment value, ex: %{HOSTNAME}

func FormatWithTime added in v0.2.0

func FormatWithTime(text string) (result string)

FormatWithTime format string with current time, ex: %{+2006-01-02}

func ReflectConfig

func ReflectConfig(confraw *ConfigRaw, conf interface{}) (err error)

ReflectConfig Reflect config.

func RegistFilterHandler

func RegistFilterHandler(name string, handler FilterHandler)

RegistFilterHandler Registe FilterHandler.

func RegistInputHandler

func RegistInputHandler(name string, handler InputHandler)

Registe InputHandler.

func RegistOutputHandler

func RegistOutputHandler(name string, handler OutputHandler)

Registe OutputHandler.

Types

type CommonConfig

type CommonConfig struct {
	inject.Injector `json:"-"`
	Type            string `json:"type"`
}

CommonConfig Common config for logcool.

func (*CommonConfig) GetType

func (c *CommonConfig) GetType() string

GetType Get config type.

func (*CommonConfig) Invoke

func (c *CommonConfig) Invoke(f interface{}) (refvs []reflect.Value, err error)

Invoke all reflect-values.

func (*CommonConfig) SetInjector

func (c *CommonConfig) SetInjector(inj inject.Injector)

SetInjector Set injector value.

type Config

type Config struct {
	inject.Injector `json:"-"`
	InputRaw        []ConfigRaw `json:"input"`
	FilterRaw       []ConfigRaw `json:"filter"`
	OutputRaw       []ConfigRaw `json:"output"`
}

Config config struct for config-raw.

func LoadDefaultConfig

func LoadDefaultConfig(ctx context.Context) (config Config, err error)

LoadDefaultConfig Load default-config from string.

func LoadFromData

func LoadFromData(ctx context.Context, data []byte) (config Config, err error)

LoadFromData Load config from data([]byte).

func LoadFromFile

func LoadFromFile(ctx context.Context, path string) (config Config, err error)

LoadFromFile Load config from file.

func LoadFromString

func LoadFromString(ctx context.Context, text string) (config Config, err error)

LoadFromString Load config from string.

func (*Config) Init added in v0.3.1

func (c *Config) Init(ctx context.Context)

func (*Config) InvokeSimple

func (c *Config) InvokeSimple(arg interface{}) (err error)

InvokeSimple Simple-invoke.

func (*Config) RunFilters

func (c *Config) RunFilters() (err error)

RunFilters Run Filters

func (*Config) RunInputs

func (c *Config) RunInputs() (err error)

Run Inputs.

func (*Config) RunOutputs

func (c *Config) RunOutputs() (err error)

Run Outputs.

type ConfigRaw

type ConfigRaw map[string]interface{}

ConfigRaw config raw type.

type FilterConfig

type FilterConfig struct {
	CommonConfig
}

FilterConfig Filter base type struct.

type FilterHandler

type FilterHandler interface{}

FilterHandler type interface.

type InChan

type InChan chan LogEvent

InChan In chan.

type InputConfig

type InputConfig struct {
	CommonConfig
}

Input base type struct.

type InputHandler

type InputHandler interface{}

InputHandler type interface.

type LogEvent added in v0.2.0

type LogEvent struct {
	Timestamp time.Time  `json:"timestamp"`
	Message   string     `json:"message"`
	Tags      []string   `json:"tags,omitempty"`
	Extra     echo.Store `json:"-"`
}

LogEvent struct that is also the Based struct.

func (*LogEvent) AddTag added in v0.2.0

func (le *LogEvent) AddTag(tags ...string)

AddTag for LogEvent Tags

func (LogEvent) Format added in v0.2.0

func (le LogEvent) Format(format string) (out string)

Format return string with current time / LogEvent field / ENV, ex: %{hostname}

func (LogEvent) Get added in v0.2.0

func (le LogEvent) Get(field string) (v interface{})

Get Value form LogEvent'Key

func (LogEvent) GetString added in v0.2.0

func (le LogEvent) GetString(field string) (v string)

GetString Get Value-String form LogEvent'Key

func (LogEvent) MarshalIndent added in v0.2.0

func (le LogEvent) MarshalIndent() (data []byte, err error)

MarshalIndent Marshal LogEvent to Indent

func (LogEvent) MarshalJSON added in v0.2.0

func (le LogEvent) MarshalJSON() (data []byte, err error)

MarshalJSON Marshal LogEvent to Json

type OutChan

type OutChan chan LogEvent

OutChan Out chan.

type OutputConfig

type OutputConfig struct {
	CommonConfig
}

Output base type struct.

type OutputHandler

type OutputHandler interface{}

OutputHandler type interface.

type TypeConfig

type TypeConfig interface {
	SetInjector(inj inject.Injector)
	GetType() string
	Invoke(f interface{}) (refvs []reflect.Value, err error)
}

TypeConfig Config struct for the logcool.

type TypeFilterConfig

type TypeFilterConfig interface {
	TypeConfig
	Event(LogEvent) LogEvent
}

TypeFilterConfig Filter base type interface.

type TypeInputConfig

type TypeInputConfig interface {
	TypeConfig
	Start()
}

Input base type interface.

type TypeOutputConfig

type TypeOutputConfig interface {
	TypeConfig
	Event(ctx context.Context, event LogEvent) (err error)
}

Output base type interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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