log

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 19 Imported by: 2

Documentation

Index

Constants

View Source
const (
	HookVendorFluentd  = "fluentd"
	HookVendorLogstash = "logstash"
	HookVendorSlack    = "slack"
)
View Source
const (
	TraceLevel = Level(logrus.TraceLevel)
	DebugLevel = Level(logrus.DebugLevel)
	InfoLevel  = Level(logrus.InfoLevel)
	WarnLevel  = Level(logrus.WarnLevel)
	ErrorLevel = Level(logrus.ErrorLevel)
	FatalLevel = Level(logrus.FatalLevel)
	PanicLevel = Level(logrus.PanicLevel)
)
View Source
const (
	FieldKeyWallet  = "wallet"
	FieldKeyChain   = "chain"
	FieldKeyModule  = "module"
	FieldKeyService = "service"
	FieldKeyPrefix  = "prefix"
)
View Source
const DefaultHTTPTimeout = 10 // 10 seconds; wait until 10 seconds before HTTP request times out
View Source
const (
	LogTimeLayout = "15:04:05.000000"
)
View Source
const MAX_PAYLOAD_SIZE = 100000 //100K bytes; HTTP POST request have >= 2MB, but depends upon server
View Source
const RATE_LIMIT = 1000 // in milliseconds; rate limit of slack is 1 request per second
View Source
const STACK_LEN = 1000 // size of buffer that holds logrus entries

Variables

View Source
var Trace, Print, Debug, Info, Warn, Error, Panic, Fatal func(args ...interface{})
View Source
var Tracef, Printf, Debugf, Infof, Warnf, Errorf, Panicf, Fatalf func(format string, args ...interface{})
View Source
var Traceln, Println, Debugln, Infoln, Warnln, Errorln, Panicln, Fatalln func(args ...interface{})

Functions

func AddForwarder

func AddForwarder(c *ForwarderConfig) error

func NewWriter

func NewWriter(cfg *WriterConfig) (io.Writer, error)

func SetGlobalLogger

func SetGlobalLogger(logger Logger)

Types

type Fields

type Fields logrus.Fields

type ForwarderConfig

type ForwarderConfig struct {
	Vendor     string                 `json:"vendor"`
	Address    string                 `json:"address"`
	Level      string                 `json:"level"`
	Name       string                 `json:"name"`
	TimeFormat string                 `json:"time_format,omitempty"`
	Options    map[string]interface{} `json:"options,omitempty"`
}

func (*ForwarderConfig) HookLevels

func (c *ForwarderConfig) HookLevels() ([]logrus.Level, error)

func (*ForwarderConfig) NetworkAndHostPort

func (c *ForwarderConfig) NetworkAndHostPort(defaultNet string) (network string, hostPort string, err error)

func (*ForwarderConfig) UnmarshalByOptions

func (c *ForwarderConfig) UnmarshalByOptions(v interface{}) error

type HookCreater

type HookCreater func(c *ForwarderConfig) (logrus.Hook, error)

type HookWrapper

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

func (*HookWrapper) Fire

func (h *HookWrapper) Fire(e *logrus.Entry) error

func (*HookWrapper) Levels

func (h *HookWrapper) Levels() []logrus.Level

type Level

type Level int

func ParseLevel

func ParseLevel(s string) (Level, error)

func (Level) String

func (l Level) String() string

type Logger

type Logger interface {
	Print(args ...interface{})
	Printf(format string, args ...interface{})
	Println(args ...interface{})

	Trace(args ...interface{})
	Tracef(format string, args ...interface{})
	Traceln(args ...interface{})

	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
	Debugln(args ...interface{})

	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Infoln(args ...interface{})

	Warn(args ...interface{})
	Warnf(format string, args ...interface{})
	Warnln(args ...interface{})

	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Errorln(args ...interface{})

	Panic(args ...interface{})
	Panicf(format string, args ...interface{})
	Panicln(args ...interface{})

	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
	Fatalln(args ...interface{})

	Log(level Level, args ...interface{})
	Logf(level Level, format string, args ...interface{})
	Logln(level Level, args ...interface{})

	WithFields(Fields) Logger
	SetReportCaller(yn bool)
	SetLevel(lv Level)
	GetLevel() Level
	SetConsoleLevel(lv Level)
	GetConsoleLevel() Level
	SetModuleLevel(mod string, lv Level)
	GetModuleLevel(mod string) Level
	Writer() *io.PipeWriter
	WriterLevel(lv Level) *io.PipeWriter
	SetFileWriter(writer io.Writer) error
	// contains filtered or unexported methods
}

func GlobalLogger

func GlobalLogger() Logger

func New

func New() Logger

func WithFields

func WithFields(fields Fields) Logger

type SlackHook

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

func NewSlackClient

func NewSlackClient(url string, lvs []logrus.Level) (*SlackHook, error)

func (*SlackHook) Fire

func (sh *SlackHook) Fire(e *logrus.Entry) (err error)

Fire is called for every logging invocation So, minimize processing overhead inside this function

func (*SlackHook) Levels

func (sh *SlackHook) Levels() []logrus.Level

type WriterConfig

type WriterConfig struct {
	Filename   string `json:"filename"`
	MaxSize    int    `json:"maxsize"`
	MaxAge     int    `json:"maxage"`
	MaxBackups int    `json:"maxbackups"`
	LocalTime  bool   `json:"localtime"`
	Compress   bool   `json:"compress"`
}

Jump to

Keyboard shortcuts

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