forked from navilg/namecheap-ddns-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
36 lines (30 loc) · 851 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
package main
import (
"fmt"
"log"
"os"
)
const (
ErrorLog string = "ERROR"
InformationLog string = "INFO"
WarningLog string = "WARN"
)
func DDNSLogger(logType, hosts, domain, message string) {
var (
StdoutInfoLogger *log.Logger
StdoutWarningLogger *log.Logger
StdoutErrorLogger *log.Logger
)
StdoutInfoLogger = log.New(os.Stdout, "INFO ", log.Ldate|log.Ltime)
StdoutWarningLogger = log.New(os.Stdout, "WARNING ", log.Ldate|log.Ltime)
StdoutErrorLogger = log.New(os.Stdout, "ERROR ", log.Ldate|log.Ltime)
if logType == "INFO" {
StdoutInfoLogger.Println(hosts+"."+domain, message)
} else if logType == "WARN" {
StdoutWarningLogger.Println(hosts+"."+domain, message)
} else if logType == "ERROR" {
StdoutErrorLogger.Println(hosts+"."+domain, message)
} else {
fmt.Println(hosts+"."+domain, message)
}
}