-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (32 loc) · 815 Bytes
/
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
package main
import (
"os"
"strings"
"spectacle/cmd"
"spectacle/logger"
)
func init() {
// TODO: Load the .env file and decide if colors are needed in logs
ifColorsStr := os.Getenv("COLORED_LOGS")
ifColorsStr = strings.ToLower(ifColorsStr)
ifColors := false
if ifColorsStr == "yes" || ifColorsStr == "true" {
ifColors = true
}
logLevelStr := os.Getenv("LOG_LEVEL")
logLevelStr = strings.ToLower(logLevelStr)
logLevel := "debug"
if logLevelStr != "" {
logLevel = logLevelStr
}
// By default, the color are not present
// and log level is debug
logger.Log = logger.NewLogger(logLevel, ifColors)
logger.Log.Debugf("Started logging with colors: %v and logLevel %v", ifColors, logLevel)
}
func main() {
if err := cmd.Execute(); err != nil {
logger.Log.Errorf("%+v", err)
os.Exit(1)
}
}