Logging changes

This commit is contained in:
Joona Hoikkala
2016-11-23 16:42:39 +02:00
parent 47ce432681
commit f32c4940e1
2 changed files with 8 additions and 7 deletions

View File

@ -28,7 +28,6 @@ connection = "acme-dns.db"
[api]
# domain name to listen requests for, mandatory if using tls = "letsencrypt"
# use "" (empty string) to bind to all interfaces
api_domain = ""
# listen port, eg. 443 for default HTTPS
port = "8080"
@ -43,11 +42,11 @@ corsorigins = [
]
[logconfig]
# logging level
# logging level: "error", "warning", "info" or "debug"
loglevel = "debug"
# possible values: stdout, file
logtype = "stdout"
# file path for logfile
logfile = "./acme-dns.log"
# format
logformat = "%{time:15:04:05.000} %{shortfunc} - %{level:.4s} %{id:03x} %{message}"
# format
logformat = "[%{time:2006/01/02 15:04:05.000}] - %{level: 5s} - %{message}"

View File

@ -45,9 +45,11 @@ func main() {
defer logfh.Close()
logBackend = logging.NewLogBackend(logfh, "", 0)
}
logLevel := logging.AddModuleLevel(logBackend)
logFormatter := logging.NewBackendFormatter(logBackend, logformat)
logLevel := logging.AddModuleLevel(logFormatter)
switch DNSConf.Logconfig.Level {
default:
logLevel.SetLevel(logging.DEBUG, "")
case "warning":
logLevel.SetLevel(logging.WARNING, "")
case "error":
@ -55,7 +57,6 @@ func main() {
case "info":
logLevel.SetLevel(logging.INFO, "")
}
logFormatter := logging.NewBackendFormatter(logLevel, logformat)
logging.SetBackend(logFormatter)
// Read the default records in
@ -82,6 +83,7 @@ func main() {
// API server and endpoints
api := iris.New()
api.Config.DisableBanner = true
crs := cors.New(cors.Options{
AllowedOrigins: DNSConf.API.CorsOrigins,
AllowedMethods: []string{"GET", "POST"},