# README
debug-log
The debug-log
Go package (imported as debug
) provides a thin logger inspired by the NPM's
debug package. It outputs the log messages depending on the
DEBUG environment variable.
Example of usage:
package main
import (
"os"
"github.com/davidmz/debug-log"
)
func main() {
_ = os.Setenv("DEBUG", "myproject:*")
testLogger := debug.NewLogger("myproject:test")
testLogger.Println("log line")
// Output: TIMESTAMP [myproject:test] log line
}
# Functions
NewLogger creates a new named logger with the given options.
UseEnvSource allows to use custom source of DEBUG value.
UseEnvString sets the constant string as the DEBUG value.
UseEnvVar allow logger to use the given environment variable as DEBUG value.
WithOutput sets the output writer for the logger.
WithoutTime excludes the timestamps from log output.
WithPrefix sets the prefix for the logger.
# Type aliases
EnvSourceFunc is a type of function that returns a DEBUG value.
Options is just a list of Option.