modulepackage
0.0.0-20200124120248-8fac4d71de01
Repository: https://github.com/b4b4r07/go-cli-log.git
Documentation: pkg.go.dev
# README
go-cli-log
This package provides Terraform-like log system for your CLI tool.
The log level defaults to TRACE
, DEBUG
, INFO
, WARN
, ERROR
.
$ go get github.com/b4b4r07/go-cli-log
Example
clilog.Env = "YOUR_APP_LOG"
clilog.SetOutput()
log.Printf("[INFO] run main function")
$ YOUR_APP_LOG=trace go run _example/main.go
2020/01/24 20:49:35 [INFO] run main function
License
MIT
# Functions
IsDebugOrHigher returns whether or not the current log level is debug or trace.
IsEnabled returns true if something log level is set.
LogLevel returns the current log level string based the environment vars.
LogOutput determines where we should send logs (if anywhere) and the log level.
NewTransport returns a new transport, wrapper layer for logging.
SetOutput checks for a log destination with LogOutput, and calls log.SetOutput with the result.
# Variables
These are the environmental variables that determine if we log, and if we log whether or not the log should go to a file.
These are the environmental variables that determine if we log, and if we log whether or not the log should go to a file.
ValidLevels is a list of valid log levels.