forked from terraform-linters/tflint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (39 loc) · 1.13 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"fmt"
"log"
"os"
"path"
"runtime"
"strings"
"github.com/hashicorp/logutils"
colorable "github.com/mattn/go-colorable"
"github.com/wata727/tflint/cmd"
)
func main() {
cli := cmd.NewCLI(colorable.NewColorable(os.Stdout), colorable.NewColorable(os.Stderr))
filter := &logutils.LevelFilter{
Levels: []logutils.LogLevel{"DEBUG", "INFO", "WARN", "ERROR"},
MinLevel: logutils.LogLevel(strings.ToUpper(os.Getenv("TFLINT_LOG"))),
Writer: os.Stderr,
}
log.SetOutput(filter)
log.SetFlags(log.Ltime | log.Lshortfile)
defer func() {
if r := recover(); r != nil {
fmt.Fprintf(os.Stderr, "Panic: %v\n", r)
for depth := 0; ; depth++ {
pc, src, line, ok := runtime.Caller(depth)
if !ok {
break
}
fmt.Fprintf(os.Stderr, " -> %d: %s: %s(%d)\n", depth, runtime.FuncForPC(pc).Name(), strings.Replace(src, path.Dir(src), "", 1), line)
}
fmt.Fprintln(os.Stderr, `
TFLint crashed... :(
Please attach an output log, describe the situation and version that occurred and post an issue to https://github.com/wata727/tflint/issues`)
os.Exit(cmd.ExitCodeError)
}
}()
os.Exit(cli.Run(os.Args))
}