mirror of
https://github.com/joohoi/acme-dns.git
synced 2025-07-29 06:08:10 +07:00
Logging changes
This commit is contained in:
@ -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}"
|
||||
|
8
main.go
8
main.go
@ -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"},
|
||||
|
Reference in New Issue
Block a user