utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

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)

Reflect config.

func RegistFilterHandler

func RegistFilterHandler(name string, handler FilterHandler)

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"`
}

Common config for logcool.

func (*CommonConfig) GetType

func (c *CommonConfig) GetType() string

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)

Set injector value.

type Config

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

config struct for config-raw.

func LoadDefaultConfig

func LoadDefaultConfig() (config Config, err error)

Laod default-config from string.

func LoadFromData

func LoadFromData(data []byte) (config Config, err error)

Load config from data([]byte).

func LoadFromFile

func LoadFromFile(path string) (config Config, err error)

Load config from file.

func LoadFromString

func LoadFromString(text string) (config Config, err error)

Laod config from string.

func (*Config) InvokeSimple

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

Simple-invoke.

func (*Config) RunFilters

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

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{}

config raw type.

type FilterConfig

type FilterConfig struct {
	CommonConfig
}

Filter base type struct.

type FilterHandler

type FilterHandler interface{}

FilterHandler type interface.

type InChan

type InChan chan LogEvent

In/Out 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     map[string]interface{} `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)

Get Value-String form LogEvent'Key

func (LogEvent) MarshalIndent added in v0.2.0

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

Marshal LogEvent to Indent

func (LogEvent) MarshalJSON added in v0.2.0

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

Marshal LogEvent to Json

type OutChan

type OutChan chan LogEvent

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)
}

Config struct for the logcool.

type TypeFilterConfig

type TypeFilterConfig interface {
	TypeConfig
	Event(LogEvent) LogEvent
}

Filter base type interface.

type TypeInputConfig

type TypeInputConfig interface {
	TypeConfig
	Start()
}

Input base type interface.

type TypeOutputConfig

type TypeOutputConfig interface {
	TypeConfig
	Event(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