Logging changes
This commit is contained in:
parent
47ce432681
commit
f32c4940e1
@ -28,7 +28,6 @@ connection = "acme-dns.db"
|
|||||||
|
|
||||||
[api]
|
[api]
|
||||||
# domain name to listen requests for, mandatory if using tls = "letsencrypt"
|
# domain name to listen requests for, mandatory if using tls = "letsencrypt"
|
||||||
# use "" (empty string) to bind to all interfaces
|
|
||||||
api_domain = ""
|
api_domain = ""
|
||||||
# listen port, eg. 443 for default HTTPS
|
# listen port, eg. 443 for default HTTPS
|
||||||
port = "8080"
|
port = "8080"
|
||||||
@ -43,11 +42,11 @@ corsorigins = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[logconfig]
|
[logconfig]
|
||||||
# logging level
|
# logging level: "error", "warning", "info" or "debug"
|
||||||
loglevel = "debug"
|
loglevel = "debug"
|
||||||
# possible values: stdout, file
|
# possible values: stdout, file
|
||||||
logtype = "stdout"
|
logtype = "stdout"
|
||||||
# file path for logfile
|
# file path for logfile
|
||||||
logfile = "./acme-dns.log"
|
logfile = "./acme-dns.log"
|
||||||
# format
|
# format
|
||||||
logformat = "%{time:15:04:05.000} %{shortfunc} - %{level:.4s} %{id:03x} %{message}"
|
logformat = "[%{time:2006/01/02 15:04:05.000}] - %{level: 5s} - %{message}"
|
||||||
|
|||||||
8
main.go
8
main.go
@ -45,9 +45,11 @@ func main() {
|
|||||||
defer logfh.Close()
|
defer logfh.Close()
|
||||||
logBackend = logging.NewLogBackend(logfh, "", 0)
|
logBackend = logging.NewLogBackend(logfh, "", 0)
|
||||||
}
|
}
|
||||||
|
logFormatter := logging.NewBackendFormatter(logBackend, logformat)
|
||||||
logLevel := logging.AddModuleLevel(logBackend)
|
logLevel := logging.AddModuleLevel(logFormatter)
|
||||||
switch DNSConf.Logconfig.Level {
|
switch DNSConf.Logconfig.Level {
|
||||||
|
default:
|
||||||
|
logLevel.SetLevel(logging.DEBUG, "")
|
||||||
case "warning":
|
case "warning":
|
||||||
logLevel.SetLevel(logging.WARNING, "")
|
logLevel.SetLevel(logging.WARNING, "")
|
||||||
case "error":
|
case "error":
|
||||||
@ -55,7 +57,6 @@ func main() {
|
|||||||
case "info":
|
case "info":
|
||||||
logLevel.SetLevel(logging.INFO, "")
|
logLevel.SetLevel(logging.INFO, "")
|
||||||
}
|
}
|
||||||
logFormatter := logging.NewBackendFormatter(logLevel, logformat)
|
|
||||||
logging.SetBackend(logFormatter)
|
logging.SetBackend(logFormatter)
|
||||||
|
|
||||||
// Read the default records in
|
// Read the default records in
|
||||||
@ -82,6 +83,7 @@ func main() {
|
|||||||
|
|
||||||
// API server and endpoints
|
// API server and endpoints
|
||||||
api := iris.New()
|
api := iris.New()
|
||||||
|
api.Config.DisableBanner = true
|
||||||
crs := cors.New(cors.Options{
|
crs := cors.New(cors.Options{
|
||||||
AllowedOrigins: DNSConf.API.CorsOrigins,
|
AllowedOrigins: DNSConf.API.CorsOrigins,
|
||||||
AllowedMethods: []string{"GET", "POST"},
|
AllowedMethods: []string{"GET", "POST"},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user