logit

package
v0.1.2-0...-9646a31 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2021 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterParser

func RegisterParser(name string, parser Parser)

Types

type AWSHandler

type AWSHandler struct {
	BaseHandler
	Region     string
	Group      string
	Stream     string
	MaxRetries int `toml:"max_retries"`
	SSL        bool
}

func NewAWSHandler

func NewAWSHandler() AWSHandler

func (AWSHandler) Parse

func (config AWSHandler) Parse() (Handler, error)

type BaseHandler

type BaseHandler struct {
	LevelFrom string `toml:"level_from"`
	LevelTo   string `toml:"level_to"`
	File      string
	Mode      os.FileMode
	Workers   int
}

func NewBaseHandler

func NewBaseHandler() BaseHandler

func (BaseHandler) Parse

func (config BaseHandler) Parse() (Handler, error)

type CFields

type CFields struct {
	Message string
	Level   string
	Time    string
}

type CHandler

type CHandler struct {
	Format string
}

type CLevels

type CLevels struct {
	Default string `toml:"default"`
	Error   string `toml:"error"`
}

type DiscordHandler

type DiscordHandler struct {
	BaseHandler
	URL       string
	Username  string
	Author    string
	Inline    bool
	Timestamp string
}

func NewDiscordHandler

func NewDiscordHandler() DiscordHandler

func (DiscordHandler) Parse

func (config DiscordHandler) Parse() (Handler, error)

type ElasticHandler

type ElasticHandler struct {
	BaseHandler
	URLs  []string
	Host  string
	Index string
}

func NewElasticHandler

func NewElasticHandler() ElasticHandler

func (ElasticHandler) Parse

func (config ElasticHandler) Parse() (Handler, error)

type FluentdHandler

type FluentdHandler struct {
	BaseHandler
	Host     string
	Port     int
	MaxRetry int `toml:"max_retry"`
}

func NewFluentdHandler

func NewFluentdHandler() FluentdHandler

func (FluentdHandler) Parse

func (config FluentdHandler) Parse() (Handler, error)

type GCloudHandler

type GCloudHandler struct {
	BaseHandler
	Credentials string
	Endpoint    string
	Labels      map[string]string
	LogName     string `toml:"log_name"`
	ProjectId   string `toml:"project_id"`
}

func NewGCloudHandler

func NewGCloudHandler() GCloudHandler

func (GCloudHandler) Parse

func (config GCloudHandler) Parse() (Handler, error)

type GCloudHook

type GCloudHook struct {
	// contains filtered or unexported fields
}

func (*GCloudHook) Fire

func (h *GCloudHook) Fire(entry *logrus.Entry) error

func (*GCloudHook) Levels

func (*GCloudHook) Levels() []logrus.Level

type GraylogHandler

type GraylogHandler struct {
	BaseHandler
	Address string
}

func NewGraylogHandler

func NewGraylogHandler() GraylogHandler

func (GraylogHandler) Parse

func (config GraylogHandler) Parse() (Handler, error)

type Handler

type Handler interface {
	Wait()
	Log(*logrus.Entry) error
	SetFormatter(logrus.Formatter)
	SetHook(logrus.Hook)
	SetStream(io.Writer)
}

func ParseHandler

func ParseHandler(meta toml.MetaData, primitive toml.Primitive) (Handler, error)

type HandlerAsync

type HandlerAsync struct {
	// contains filtered or unexported fields
}

func (*HandlerAsync) Log

func (h *HandlerAsync) Log(entry *logrus.Entry) error

func (*HandlerAsync) SetFormatter

func (handler *HandlerAsync) SetFormatter(f logrus.Formatter)

func (*HandlerAsync) SetHook

func (handler *HandlerAsync) SetHook(hook logrus.Hook)

func (*HandlerAsync) SetStream

func (handler *HandlerAsync) SetStream(stream io.Writer)

func (*HandlerAsync) Wait

func (h *HandlerAsync) Wait()

type HandlerSync

type HandlerSync struct {
	// contains filtered or unexported fields
}

func (HandlerSync) Log

func (handler HandlerSync) Log(entry *logrus.Entry) error

func (*HandlerSync) SetFormatter

func (handler *HandlerSync) SetFormatter(f logrus.Formatter)

func (*HandlerSync) SetHook

func (handler *HandlerSync) SetHook(hook logrus.Hook)

func (*HandlerSync) SetStream

func (handler *HandlerSync) SetStream(stream io.Writer)

func (HandlerSync) Wait

func (handler HandlerSync) Wait()

type InfluxDBHandler

type InfluxDBHandler struct {
	BaseHandler

	Host     string
	Port     int
	Username string
	Password string

	Database   string
	Precision  string
	UseHTTPS   bool `toml:"use_https"`
	BatchCount int  `toml:"batch_count"`
}

func NewInfluxDBHandler

func NewInfluxDBHandler() InfluxDBHandler

func (InfluxDBHandler) Parse

func (config InfluxDBHandler) Parse() (Handler, error)

type JSONHandler

type JSONHandler struct {
	BaseHandler
	DataKey   string `toml:"data_key"`
	Timestamp string
}

func NewJSONHandler

func NewJSONHandler() JSONHandler

func (JSONHandler) Parse

func (config JSONHandler) Parse() (Handler, error)

type Levels

type Levels struct {
	Default logrus.Level
	Error   logrus.Level
}

Levels represent configuration for default levels

type LogFmtHandler

type LogFmtHandler struct {
	BaseHandler
	Timestamp string
	Sort      bool
}

func NewLogFmtHandler

func NewLogFmtHandler() LogFmtHandler

func (LogFmtHandler) Parse

func (config LogFmtHandler) Parse() (Handler, error)

type Logger

type Logger struct {
	Levels   Levels
	Handlers []Handler
	Fields   CFields
	Defaults logrus.Fields
	// contains filtered or unexported fields
}

func MakeLogger

func MakeLogger(content string) (*Logger, error)

MakeLogger parses the given configuration file and returns Logger instance.

func ReadLogger

func ReadLogger(cpath string) (*Logger, error)

ReadLogger reads configuration file by the given path and returns Logger instance.

func (Logger) Log

func (log Logger) Log(entry *logrus.Entry) error

func (Logger) Parse

func (log Logger) Parse(line string) (*logrus.Entry, error)

func (Logger) SafeParse

func (log Logger) SafeParse(line string) *logrus.Entry

func (*Logger) SetStream

func (log *Logger) SetStream(stream io.Writer)

func (Logger) Wait

func (log Logger) Wait()

type LogglyHandler

type LogglyHandler struct {
	BaseHandler
	Token string
	Host  string
	Tags  []string
}

func NewLogglyHandler

func NewLogglyHandler() LogglyHandler

func (LogglyHandler) Parse

func (config LogglyHandler) Parse() (Handler, error)

type LogstashHandler

type LogstashHandler struct {
	BaseHandler
	Network string
	Address string
	Version string
	Type    string
}

func NewLogstashHandler

func NewLogstashHandler() LogstashHandler

func (LogstashHandler) Parse

func (config LogstashHandler) Parse() (Handler, error)

type MongoDBHandler

type MongoDBHandler struct {
	BaseHandler
	URL        string
	DB         string
	Collection string
}

func NewMongoDBHandler

func NewMongoDBHandler() MongoDBHandler

func (MongoDBHandler) Parse

func (config MongoDBHandler) Parse() (Handler, error)

type Parser

type Parser func(meta toml.MetaData, primitive toml.Primitive) (Handler, error)

type Parsers

type Parsers map[string]Parser

type RawConfig

type RawConfig struct {
	Levels      CLevels
	Fields      CFields
	Defaults    logrus.Fields
	HandlersRaw []toml.Primitive `toml:"handler"`
}

RawConfig represents the struct to parse TOML config into.

type RedisHandler

type RedisHandler struct {
	BaseHandler

	Host     string
	Port     int
	Password string

	Key        string
	Format     string
	App        string
	SourceHost string `toml:"source_host"`
	Database   int
	TTL        string
}

func NewRedisHandler

func NewRedisHandler() RedisHandler

func (RedisHandler) Parse

func (config RedisHandler) Parse() (Handler, error)

type RollingHandler

type RollingHandler struct {
	BaseHandler
	SubHandler toml.Primitive `toml:"handler"`

	File       string `toml:"file"`
	MaxSize    int    `toml:"max_size"`
	MaxAge     int    `toml:"max_age"`
	MaxBackups int    `toml:"max_backups"`
	LocalTime  bool   `toml:"local_time"`
	Compress   bool   `toml:"compress"`
}

func NewRollingHandler

func NewRollingHandler() RollingHandler

func (RollingHandler) Parse

func (config RollingHandler) Parse() (Handler, error)

type SentryHandler

type SentryHandler struct {
	BaseHandler
	DSN     string
	Timeout string
}

func NewSentryHandler

func NewSentryHandler() SentryHandler

func (SentryHandler) Parse

func (config SentryHandler) Parse() (Handler, error)

type SlackHandler

type SlackHandler struct {
	BaseHandler
	HookURL   string `toml:"hook_url"`
	IconURL   string `toml:"icon_url"`
	Channel   string
	IconEmoji string `toml:"icon_emoji"`
	Username  string
}

func NewSlackHandler

func NewSlackHandler() SlackHandler

func (SlackHandler) Parse

func (config SlackHandler) Parse() (Handler, error)

type SysLogHandler

type SysLogHandler struct {
	BaseHandler
	Network  string
	Address  string
	Tag      string
	Priority string
}

func NewSysLogHandler

func NewSysLogHandler() SysLogHandler

func (SysLogHandler) Parse

func (config SysLogHandler) Parse() (Handler, error)

type TextHandler

type TextHandler struct {
	BaseHandler
	Timestamp     string
	Sort          bool
	TruncateLevel bool `toml:"truncate_level"`
}

func NewTextHandler

func NewTextHandler() TextHandler

func (TextHandler) Parse

func (config TextHandler) Parse() (Handler, error)

type ZalgoHandler

type ZalgoHandler struct {
	BaseHandler
}

func NewZalgoHandler

func NewZalgoHandler() ZalgoHandler

func (ZalgoHandler) Parse

func (config ZalgoHandler) Parse() (Handler, error)

Jump to

Keyboard shortcuts

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