luci-app-mosdns/mosdns/patches/200-add-debug-log-again.patch

69 lines
2.4 KiB
Diff

From 3f57bcbf18fc5a537a4365ce1e5f5798db3a9dc6 Mon Sep 17 00:00:00 2001
From: sbwml <admin@cooluc.com>
Date: Sun, 25 Jun 2023 06:50:27 +0800
Subject: [PATCH 10/10] add debug log again
---
pkg/server/http_handler.go | 1 +
pkg/server_handler/entry_handler.go | 2 ++
pkg/upstream/bootstrap/bootstrap.go | 2 +-
plugin/executable/cache/cache.go | 3 +++
4 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/pkg/server/http_handler.go b/pkg/server/http_handler.go
index 58f5811..5fa76b4 100644
--- a/pkg/server/http_handler.go
+++ b/pkg/server/http_handler.go
@@ -94,6 +94,7 @@ func (h *HttpHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
if err != nil {
h.warnErr(req, "invalid request", err)
w.WriteHeader(http.StatusBadRequest)
+ w.Write([]byte("Bad Request"))
return
}
diff --git a/pkg/server_handler/entry_handler.go b/pkg/server_handler/entry_handler.go
index 520e3d2..38df952 100644
--- a/pkg/server_handler/entry_handler.go
+++ b/pkg/server_handler/entry_handler.go
@@ -87,6 +87,8 @@ func (h *EntryHandler) Handle(ctx context.Context, q *dns.Msg, qInfo server.Quer
respMsg := qCtx.R()
if err != nil {
h.opts.Logger.Warn("entry err", qCtx.InfoField(), zap.Error(err))
+ } else {
+ h.opts.Logger.Debug("entry returned", qCtx.InfoField())
}
if err == nil && respMsg == nil {
diff --git a/pkg/upstream/bootstrap/bootstrap.go b/pkg/upstream/bootstrap/bootstrap.go
index 2cd8ef9..5192053 100644
--- a/pkg/upstream/bootstrap/bootstrap.go
+++ b/pkg/upstream/bootstrap/bootstrap.go
@@ -117,7 +117,7 @@ func (sp *Bootstrap) tryUpdate() {
if updateInterval < minimumUpdateInterval {
updateInterval = minimumUpdateInterval
}
- sp.logger.Info(
+ sp.logger.Debug(
"bootstrap addr updated",
zap.String("fqdn", sp.fqdn),
zap.Stringer("addr", addr),
diff --git a/plugin/executable/cache/cache.go b/plugin/executable/cache/cache.go
index 58162ee..dd833dc 100644
--- a/plugin/executable/cache/cache.go
+++ b/plugin/executable/cache/cache.go
@@ -204,7 +204,10 @@ func (c *Cache) Exec(ctx context.Context, qCtx *query_context.Context, next sequ
c.hitTotal.Inc()
cachedResp.Id = q.Id // change msg id
shuffleIP(cachedResp)
+ c.logger.Debug("cache hit", qCtx.InfoField())
qCtx.SetResponse(cachedResp)
+ } else {
+ c.logger.Debug("cache miss", qCtx.InfoField())
}
err := next.ExecNext(ctx, qCtx)
--
2.34.8