log

package
v0.0.0-...-a6def8b Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 7 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// IsTerm instructs current stdout whether is terminal
	IsTerm bool
	// LogAccess is log access log
	LogAccess *logrus.Logger
	// LogError is log error log
	LogError *logrus.Logger
)
View Source
var DefaultConfig = &Config{
	Format:      "string",
	AccessLog:   "stdout",
	AccessLevel: "info",
	ErrorLog:    "stderr",
	ErrorLevel:  "error",
	Agent: AgentConfig{
		Enabled: false,
	},
}

DefaultConfig is default configuration

Functions

func InitLog

func InitLog(logConf *Config) error

InitLog use for initial log module

func SetLogLevel

func SetLogLevel(log *logrus.Logger, levelString string) error

SetLogLevel is define log level what you want log level: panic, fatal, error, warn, info and debug

func SetLogOut

func SetLogOut(log *logrus.Logger, outString string) error

SetLogOut provide log stdout and stderr output

Types

type AgentConfig

type AgentConfig struct {
	Enabled     bool   `yaml:"enabled"`
	DSN         string `yaml:"dsn"`
	AppID       string `yaml:"app_id"`
	Host        string `yaml:"host"`
	InstanceID  string `yaml:"instance_id"`
	Category    string `yaml:"category"`
	ChannelSize int    `yaml:"channel_size,omitempty"`
}

AgentConfig is sub section of LogConfig.

type Config

type Config struct {
	Format      string      `yaml:"format"`
	AccessLog   string      `yaml:"access_log"`
	AccessLevel string      `yaml:"access_level"`
	ErrorLog    string      `yaml:"error_log"`
	ErrorLevel  string      `yaml:"error_level"`
	Agent       AgentConfig `yaml:"agent"`
}

Config is logging config.

func GetLogConfig

func GetLogConfig() *Config

GetLogConfig return current log config

type EmptyFormatter

type EmptyFormatter struct {
}

EmptyFormatter output nothing

func NewEmptyFormatter

func NewEmptyFormatter() *EmptyFormatter

NewEmptyFormatter return the log format for output nothing

func (*EmptyFormatter) Format

func (f *EmptyFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format renders a single log entry

Jump to

Keyboard shortcuts

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