luci-app-mosdns/mosdns/patches/200-add-debug-log-again.patch
2023-09-18 14:59:04 +08:00

57 lines
2.0 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/dns_handler/entry_handler.go | 4 +++-
pkg/server/http_handler/handler.go | 1 +
plugin/executable/cache/cache.go | 3 +++
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/pkg/server/dns_handler/entry_handler.go b/pkg/server/dns_handler/entry_handler.go
index 4737811..cec4123 100644
--- a/pkg/server/dns_handler/entry_handler.go
+++ b/pkg/server/dns_handler/entry_handler.go
@@ -90,7 +90,9 @@ func (h *EntryHandler) ServeDNS(ctx context.Context, qCtx *query_context.Context
err := h.opts.Entry.Exec(ctx, qCtx)
respMsg := qCtx.R()
if err != nil {
- h.opts.Logger.Warn("entry err", qCtx.InfoField(), zap.Error(err))
+ h.opts.Logger.Warn("entry returned an err", qCtx.InfoField(), zap.Error(err))
+ } else {
+ h.opts.Logger.Debug("entry returned", qCtx.InfoField())
}
if err == nil && respMsg == nil {
diff --git a/pkg/server/http_handler/handler.go b/pkg/server/http_handler/handler.go
index 3e800f9..25f52e1 100644
--- a/pkg/server/http_handler/handler.go
+++ b/pkg/server/http_handler/handler.go
@@ -96,6 +96,7 @@ func (h *Handler) 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/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