-
Notifications
You must be signed in to change notification settings - Fork 1
/
logger.go
41 lines (35 loc) · 883 Bytes
/
logger.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
package logger
import (
"fmt"
"time"
"github.com/go-niom/niom/pkg/constants"
"github.com/gookit/color"
)
// It is the helper function to print current date-time in the logger
func printCurrentTime() {
fmt.Print(time.Now().Format(" 2006-01-02 15:04:05"))
}
// Func Info log the msg passed to it
// With Indicator INFO in green color
func Info(msg string) {
color.Bluep(constants.AppSign)
printCurrentTime()
color.Greenp(" [INFO] ")
fmt.Println(msg)
}
// Func Error log the msg and error passed to it
// With Indicator Error in red color
func Error(msg, err string) {
color.Bluep(constants.AppSign)
printCurrentTime()
color.Redp(" [ERROR] ")
fmt.Println(msg, err)
}
// Func Warn log the msg passed to it
// With Indicator Warn in yellow color
func Warn(msg string) {
color.Bluep(constants.AppSign)
printCurrentTime()
color.Yellowp(" [WARN] ")
fmt.Println(msg)
}