terraform-provider-docker/vendor/github.com/hashicorp/logutils
Matt Keeler a789ce2036 Update to Terraform 0.12 (#150). Closes #144
* Update to terraform 0.12
* Fix acceptance tests to make syntax 0.12 compatible.
2019-06-11 00:24:55 +02:00
..
.gitignore deps: use go modules for dep mgmt 2019-03-11 18:19:30 -04:00
go.mod Update to Terraform 0.12 (#150). Closes #144 2019-06-11 00:24:55 +02:00
level.go Initial transfer of provider code 2017-06-06 11:50:36 -04:00
LICENSE Initial transfer of provider code 2017-06-06 11:50:36 -04:00
README.md Initial transfer of provider code 2017-06-06 11:50:36 -04:00

logutils

logutils is a Go package that augments the standard library "log" package to make logging a bit more modern, without fragmenting the Go ecosystem with new logging packages.

The simplest thing that could possibly work

Presumably your application already uses the default log package. To switch, you'll want your code to look like the following:

package main

import (
	"log"
	"os"

	"github.com/hashicorp/logutils"
)

func main() {
	filter := &logutils.LevelFilter{
		Levels: []logutils.LogLevel{"DEBUG", "WARN", "ERROR"},
		MinLevel: logutils.LogLevel("WARN"),
		Writer: os.Stderr,
	}
	log.SetOutput(filter)

	log.Print("[DEBUG] Debugging") // this will not print
	log.Print("[WARN] Warning") // this will
	log.Print("[ERROR] Erring") // and so will this
	log.Print("Message I haven't updated") // and so will this
}

This logs to standard error exactly like go's standard logger. Any log messages you haven't converted to have a level will continue to print as before.