mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-04-30 21:21:42 +03:00
dnsforward: slog logger
This commit is contained in:
parent
3d7f734ac9
commit
5932c8d102
7 changed files with 41 additions and 4 deletions
internal/home
|
@ -6,6 +6,7 @@ import (
|
|||
"crypto/x509"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"net/netip"
|
||||
"net/url"
|
||||
|
@ -62,6 +63,9 @@ type homeContext struct {
|
|||
// configuration files, for example /etc/hosts.
|
||||
etcHosts *aghnet.HostsContainer
|
||||
|
||||
// logger is an instance of [*slog.Logger]. It is never nil.
|
||||
logger *slog.Logger
|
||||
|
||||
// mux is our custom http.ServeMux.
|
||||
mux *http.ServeMux
|
||||
|
||||
|
@ -137,12 +141,13 @@ func Main(clientBuildFS fs.FS) {
|
|||
}
|
||||
|
||||
// setupContext initializes [Context] fields. It also reads and upgrades
|
||||
// config file if necessary.
|
||||
func setupContext(opts options) (err error) {
|
||||
// config file if necessary. l must not be nil.
|
||||
func setupContext(opts options, l *slog.Logger) (err error) {
|
||||
Context.firstRun = detectFirstRun()
|
||||
|
||||
Context.tlsRoots = aghtls.SystemRootCAs()
|
||||
Context.mux = http.NewServeMux()
|
||||
Context.logger = l
|
||||
|
||||
if Context.firstRun {
|
||||
log.Info("This is the first time AdGuard Home is launched")
|
||||
|
@ -565,7 +570,7 @@ func run(opts options, clientBuildFS fs.FS, done chan struct{}) {
|
|||
l.Info("AdGuard Home is running as a service")
|
||||
}
|
||||
|
||||
err = setupContext(opts)
|
||||
err = setupContext(opts, l)
|
||||
fatalOnError(err)
|
||||
|
||||
err = configureOS(config)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue