summaryrefslogtreecommitdiff
path: root/vendor/github.com/hashicorp/terraform/vendor/github.com/posener/complete/log.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/vendor/github.com/posener/complete/log.go')
-rw-r--r--vendor/github.com/hashicorp/terraform/vendor/github.com/posener/complete/log.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/vendor/github.com/posener/complete/log.go b/vendor/github.com/hashicorp/terraform/vendor/github.com/posener/complete/log.go
new file mode 100644
index 00000000..797a80ce
--- /dev/null
+++ b/vendor/github.com/hashicorp/terraform/vendor/github.com/posener/complete/log.go
@@ -0,0 +1,23 @@
+package complete
+
+import (
+ "io"
+ "io/ioutil"
+ "log"
+ "os"
+)
+
+// Log is used for debugging purposes
+// since complete is running on tab completion, it is nice to
+// have logs to the stderr (when writing your own completer)
+// to write logs, set the COMP_DEBUG environment variable and
+// use complete.Log in the complete program
+var Log = getLogger()
+
+func getLogger() func(format string, args ...interface{}) {
+ var logfile io.Writer = ioutil.Discard
+ if os.Getenv(envDebug) != "" {
+ logfile = os.Stderr
+ }
+ return log.New(logfile, "complete ", log.Flags()).Printf
+}