Skip to content

Instantly share code, notes, and snippets.

@stephen-soltesz
Last active December 3, 2019 04:57
Show Gist options
  • Save stephen-soltesz/0ac8a299f29d99f7f953ec11dd562268 to your computer and use it in GitHub Desktop.
Save stephen-soltesz/0ac8a299f29d99f7f953ec11dd562268 to your computer and use it in GitHub Desktop.
Example usage of logx.Loggers() and logx.Setup()
import (
"flag"
"log"
"github.com/m-lab/go/flagx"
"github.com/m-lab/go/logx"
"github.com/m-lab/go/rtx"
)
// Optionally define local variables with self-describing names.
var debug = logx.Debug
func main() {
flag.Parse()
log.SetFlags(log.Ldate | log.Lmicroseconds | log.LUTC | log.Lshortfile)
rtx.Must(flagx.ArgsFromEnv(flag.CommandLine), "Failed to parse flags")
rtx.Must(logx.Setup(), "Failed to init logx package")
log.Println("this is standard log")
logx.Debug.Println("debug message")
log.Println("this is standard log")
debug.Println("inline debug message")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment