logger

package
v0.0.0-...-f30a169 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package logger contains spv logs for each module

Index

Constants

View Source
const (
	ModuleCli          = "[Cli]"
	ModuleSpv          = "[SPV]"
	ModuleStateManager = "[StateManager]"
	ModuleReqManager   = "[ReqManager]"
	ModuleBlockManager = "[BlockManager]"
	ModuleStateDB      = "[StateDB]"
	ModuleProver       = "[Prover]"
	ModuleRpc          = "[Rpc]"
	ModuleWeb          = "[Web]"
	ModuleSdk          = "[Sdk]"
)

module log name

View Source
const (
	DEBUG = "DEBUG"
	INFO  = "INFO"
	WARN  = "WARN"
	ERROR = "ERROR"
)

log level

View Source
const (
	DefaultMaxAge       = 365 // maximum log retention time,unit:day
	DefaultRotationTime = 6   // log scrolling interval,unit:hour
)

default config of log cutting

Variables

This section is empty.

Functions

func GetDefaultLogger

func GetDefaultLogger() *zap.SugaredLogger

GetDefaultLogger creates default logger

func GetLogger

func GetLogger(name string) *zap.SugaredLogger

GetLogger finds or creates a logger with module name, usually called in initialization of all module.

func SetLogConfig

func SetLogConfig(config *LogConfig)

SetLogConfig sets the config of logger module, called in initialization of config module

Types

type Config

type Config struct {
	Module       string   // module: module name
	LogPath      string   // logPath: logger file save path
	LogLevel     LogLevel // logLevel: logger level
	MaxAge       int      // maxAge: the maximum number of days to retain old logger files
	RotationTime int      // RotationTime: rotation time
	JsonFormat   bool     // jsonFormat: logger file use json format
	ShowLine     bool     // showLine: show filename and line number
	LogInConsole bool     // logInConsole: show logs in console at the same time
	ShowColor    bool     // if true, show color logger
}

type LogConfig

type LogConfig struct {
	ConfigFile string        `mapstructure:"config_file"`
	SystemLog  LogNodeConfig `mapstructure:"system"`
}

LogConfig is the config of logger module

type LogLevel

type LogLevel int

LogLevel is a type of log level

const (
	LevelDebug LogLevel = iota
	LevelInfo
	LevelWarn
	LevelError
)

func GetLogLevel

func GetLogLevel(lvl string) LogLevel

GetLogLevel gets log level

type LogNodeConfig

type LogNodeConfig struct {
	LogLevel     string `mapstructure:"log_level"`
	FilePath     string `mapstructure:"file_path"`
	MaxAge       int    `mapstructure:"max_age"`
	RotationTime int    `mapstructure:"rotation_time"`
	LogInConsole bool   `mapstructure:"log_in_console"`
	ShowColor    bool   `mapstructure:"show_color"`
}

LogNodeConfig is the logger config of node

Jump to

Keyboard shortcuts

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