File: log.go

package info (click to toggle)
golang-github-posener-complete 1.1+git20180108.57878c9-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 200 kB
  • sloc: sh: 9; makefile: 4
file content (23 lines) | stat: -rw-r--r-- 569 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
}