diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c52cc8c..7de24cee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ and this project adheres to ### Changed +- Quality of logging ([#2954]). - Normalization of hostnames with spaces sent by DHCP clients ([#2945]). - The access to the private hosts is now forbidden for users from external networks ([#2889]). @@ -81,6 +82,7 @@ and this project adheres to [#2934]: https://github.com/AdguardTeam/AdGuardHome/issues/2934 [#2945]: https://github.com/AdguardTeam/AdGuardHome/issues/2945 [#2947]: https://github.com/AdguardTeam/AdGuardHome/issues/2947 +[#2954]: https://github.com/AdguardTeam/AdGuardHome/issues/2954 [#2961]: https://github.com/AdguardTeam/AdGuardHome/issues/2961 diff --git a/go.mod b/go.mod index 0147d868..257e4576 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.15 require ( github.com/AdguardTeam/dnsproxy v0.35.5 - github.com/AdguardTeam/golibs v0.4.4 + github.com/AdguardTeam/golibs v0.4.5 github.com/AdguardTeam/urlfilter v0.14.4 github.com/NYTimes/gziphandler v1.1.1 github.com/ameshkov/dnscrypt/v2 v2.0.3 diff --git a/go.sum b/go.sum index ed7d6c27..b5554bae 100644 --- a/go.sum +++ b/go.sum @@ -24,6 +24,8 @@ github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKU github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.4.4 h1:cM9UySQiYFW79zo5XRwnaIWVzfW4eNXmZktMrWbthpw= github.com/AdguardTeam/golibs v0.4.4/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= +github.com/AdguardTeam/golibs v0.4.5 h1:RRA9ZsmbJEN4OllAx0BcfvSbRBxxpWluJijBYmtp13U= +github.com/AdguardTeam/golibs v0.4.5/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU= github.com/AdguardTeam/urlfilter v0.14.4 h1:lrS7lrfxVCFh4TFB6nwPp5UE4n1XNvv3zUetduD9mZw= github.com/AdguardTeam/urlfilter v0.14.4/go.mod h1:klx4JbOfc4EaNb5lWLqOwfg+pVcyRukmoJRvO55lL5U= diff --git a/internal/home/config.go b/internal/home/config.go index f2b0b93c..853e2483 100644 --- a/internal/home/config.go +++ b/internal/home/config.go @@ -2,6 +2,7 @@ package home import ( "errors" + "fmt" "io/ioutil" "net" "os" @@ -260,8 +261,7 @@ func readConfigFile() ([]byte, error) { configFile := config.getConfigFilename() d, err := ioutil.ReadFile(configFile) if err != nil { - log.Error("Couldn't read config file %s: %s", configFile, err) - return nil, err + return nil, fmt.Errorf("couldn't read config file %s: %w", configFile, err) } return d, nil } diff --git a/internal/home/home.go b/internal/home/home.go index 62764e4e..4a590639 100644 --- a/internal/home/home.go +++ b/internal/home/home.go @@ -163,12 +163,14 @@ func setupContext(args options) { err = parseConfig() if err != nil { - log.Error("Failed to parse configuration, exiting") + log.Error("parsing configuration file: %s", err) + os.Exit(1) } if args.checkConfig { - log.Info("Configuration file is OK") + log.Info("configuration file is ok") + os.Exit(0) } } diff --git a/internal/home/rdns.go b/internal/home/rdns.go index ea63eb83..a2f59c8c 100644 --- a/internal/home/rdns.go +++ b/internal/home/rdns.go @@ -90,7 +90,7 @@ func (r *RDNS) workerLoop() { for ip := range r.ipCh { host, err := r.exchanger.Exchange(ip) if err != nil { - log.Error("rdns: resolving %q: %s", ip, err) + log.Debug("rdns: resolving %q: %s", ip, err) continue } diff --git a/internal/home/web.go b/internal/home/web.go index 73987dcb..136e2118 100644 --- a/internal/home/web.go +++ b/internal/home/web.go @@ -171,7 +171,7 @@ func (web *Web) Start() { hostStr := web.conf.BindHost.String() // we need to have new instance, because after Shutdown() the Server is not usable web.httpServer = &http.Server{ - ErrorLog: log.StdLog("web: http", log.DEBUG), + ErrorLog: log.StdLog("web: plain", log.DEBUG), Addr: net.JoinHostPort(hostStr, strconv.Itoa(web.conf.BindPort)), Handler: withMiddlewares(Context.mux, limitRequestBody), ReadTimeout: web.conf.ReadTimeout, @@ -184,7 +184,7 @@ func (web *Web) Start() { if web.conf.BetaBindPort != 0 { web.httpServerBeta = &http.Server{ - ErrorLog: log.StdLog("web: http", log.DEBUG), + ErrorLog: log.StdLog("web: plain", log.DEBUG), Addr: net.JoinHostPort(hostStr, strconv.Itoa(web.conf.BetaBindPort)), Handler: withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta), ReadTimeout: web.conf.ReadTimeout,