Documentation ¶
Index ¶
- Constants
- func DefaultLevel() string
- func GetModuleLevel(module string) string
- func GetPeerStartupLevel(module string) string
- func InitBackend(formatter logging.Formatter, output io.Writer)
- func InitFromSpec(spec string) string
- func MustGetLogger(module string) *logging.Logger
- func Reset()
- func RevertToPeerStartupLevels() error
- func SetFormat(formatSpec string) logging.Formatter
- func SetModuleLevel(moduleRegExp string, level string) (string, error)
- func SetPeerStartupModulesMap()
Examples ¶
Constants ¶
const GRPCModuleID = "grpc"
Variables ¶
This section is empty.
Functions ¶
func DefaultLevel ¶
func DefaultLevel() string
DefaultLevel returns the fallback value for loggers to use if parsing fails.
func GetModuleLevel ¶ added in v1.0.0
GetModuleLevel gets the current logging level for the specified module.
func GetPeerStartupLevel ¶ added in v1.0.0
GetPeerStartupLevel returns the peer startup level for the specified module. It will return an empty string if the input parameter is empty or the module is not found
func InitBackend ¶ added in v1.0.0
InitBackend sets up the logging backend based on the provided logging formatter and I/O writer.
Example ¶
level, _ := logging.LogLevel(flogging.DefaultLevel()) // initializes logging backend for testing and sets time to 1970-01-01 00:00:00.000 UTC logging.InitForTesting(level) formatSpec := "%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x} %{message}" flogging.InitBackend(flogging.SetFormat(formatSpec), os.Stdout) logger := flogging.MustGetLogger("testModule") logger.Info("test output")
Output: 1970-01-01 00:00:00.000 UTC [testModule] ExampleInitBackend -> INFO 001 test output
func InitFromSpec ¶ added in v1.0.0
InitFromSpec initializes the logging based on the supplied spec. It is exposed externally so that consumers of the flogging package may parse their own logging specification. The logging specification has the following form:
[<module>[,<module>...]=]<level>[:[<module>[,<module>...]=]<level>...]
func MustGetLogger ¶
func MustGetLogger(module string) *logging.Logger
MustGetLogger is used in place of `logging.MustGetLogger` to allow us to store a map of all modules and submodules that have loggers in the system.
func RevertToPeerStartupLevels ¶ added in v1.0.0
func RevertToPeerStartupLevels() error
RevertToPeerStartupLevels reverts the log levels for all modules to the level defined at the end of peer startup.
func SetFormat ¶ added in v1.0.0
func SetFormat(formatSpec string) logging.Formatter
SetFormat sets the logging format.
func SetModuleLevel ¶ added in v1.0.0
SetModuleLevel sets the logging level for the modules that match the supplied regular expression. Can be used to dynamically change the log level for the module.
func SetPeerStartupModulesMap ¶ added in v1.0.0
func SetPeerStartupModulesMap()
SetPeerStartupModulesMap saves the modules and their log levels. this function should only be called at the end of peer startup.
Types ¶
This section is empty.