Files
AdGuardHome/internal/aghslog/aghslog.go
Dimitry Kolyshev fca0faf6d4 Pull request: AGDNS-3007-fix-ups-logger
Merge in DNS/adguard-home from AGDNS-3007-fix-ups-logger to master

Squashed commit of the following:

commit 7b198ab6f075ec0be9ab638925d65dcf16c3aa67
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Wed Jul 9 09:54:15 2025 +0400

    dnsforward: fix merge

commit dd0a680bd1b995bbe570861723f85244855de2ce
Merge: 081526039 63c64b10e
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Wed Jul 9 09:43:22 2025 +0400

    Merge remote-tracking branch 'origin/master' into AGDNS-3007-fix-ups-logger

commit 081526039fb7841ca2ca94f3effe339bfb01d295
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Mon Jul 7 17:53:37 2025 +0400

    all: imp code

commit 88b5398c8b2dce1b942ed239d488fc9dc2d342ab
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Thu Jul 3 09:59:28 2025 +0400

    all: imp code

commit c9440af9a5a21f16d126b0d494a21537fda0d339
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Thu Jul 3 09:51:44 2025 +0400

    all: imp code

commit 4aff2860eda8f5050bc0450f6c7027b1da451ab8
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Wed Jul 2 13:41:00 2025 +0400

    all: upstream dnsproxy prefix

commit 4cbc65608ec9431b6e4380a5e931cf3300b18fd0
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Wed Jul 2 13:37:45 2025 +0400

    aghslog: add dnsproxy prefix

commit fdc1ed02c380e6687fafbac973f74f461974d1d2
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Wed Jul 2 13:33:10 2025 +0400

    client: imp upstream log

commit 19438ba7e8497dc7753180d60202afa620b22df9
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Wed Jul 2 13:30:10 2025 +0400

    all: aghslog consts

commit ee5e3875c7af342412b03240cbc8c0699f431de4
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Wed Jul 2 13:26:42 2025 +0400

    dnsforward: imp tests

commit 8b8c608032658897742df38910d7f5370a26adaa
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Tue Jul 1 14:04:59 2025 +0400

    client: fix upd conf logger

commit 98227476a21fc305e9ecf62be60f1af992bac36f
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Tue Jul 1 13:26:09 2025 +0400

    next: dnssvc: use aghslog constants

commit b331ba921cac60cdd7dac6a169c7e071acba5b2b
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date:   Tue Jul 1 13:23:33 2025 +0400

    all: fix upd conf logger
2025-07-09 12:07:37 +03:00

53 lines
1.6 KiB
Go

// Package aghslog contains logging constants and helpers.
package aghslog
import (
"log/slog"
"github.com/AdguardTeam/golibs/logutil/slogutil"
)
// PrefixDNSProxy is the prefix for DNS proxy logs.
const PrefixDNSProxy = "dnsproxy"
const (
// KeyClientName is the log attribute for the client name.
KeyClientName = "client_name"
// KeyUpstreamType is the log attribute for the upstream types. See the
// UpstreamType* constants below.
KeyUpstreamType = "upstream_type"
)
const (
// UpstreamTypeBootstrap is the log attribute value for bootstrap upstreams.
UpstreamTypeBootstrap = "bootstrap"
// UpstreamTypeCustom is the log attribute value for custom upstreams.
UpstreamTypeCustom = "custom"
// UpstreamTypeFallback is the log attribute value for fallback upstreams.
UpstreamTypeFallback = "fallback"
// UpstreamTypeMain is the log attribute value for main upstreams.
UpstreamTypeMain = "main"
// UpstreamTypeLocal is the log attribute value for upstreams used for
// resolving PTR records for local addresses.
UpstreamTypeLocal = "local"
// UpstreamTypeService is the log attribute value for upstreams used for
// safe browsing and parental services.
UpstreamTypeService = "service"
// UpstreamTypeTest is the log attribute value for upstreams used for
// testing and validation.
UpstreamTypeTest = "test"
)
// NewForUpstream returns a new logger with a prefix for logs related to a
// specific upstream type.
func NewForUpstream(baseLogger *slog.Logger, typ string) (l *slog.Logger) {
return baseLogger.With(slogutil.KeyPrefix, PrefixDNSProxy, KeyUpstreamType, typ)
}