From e6617bd45f4a5f15d414f8f870151c0aed80364b Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Thu, 20 Jun 2024 15:55:15 +0300 Subject: [PATCH] all: imp adguard_legacy log, docs --- README.md | 2 -- doc/configuration.md | 14 ++++++++++---- doc/environment.md | 6 ++++++ internal/cmd/program.go | 5 +++-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 23d282a..91612b4 100644 --- a/README.md +++ b/README.md @@ -130,8 +130,6 @@ Option `--version` makes AdGuard DNS Client print out the version of the `AdGuar ## Configuration -### File - The YAML configuration file is described in the [`doc/configuration.md`] file, and there is also a sample configuration file `config.dist.yaml`. Some configuration parameters can also be overridden using the environment, see [`doc/environment.md`]. [`doc/configuration.md`]: doc/configuration.md diff --git a/doc/configuration.md b/doc/configuration.md index 0c18794..f212bfc 100644 --- a/doc/configuration.md +++ b/doc/configuration.md @@ -208,16 +208,19 @@ the following properties: ## Logging -**NOTE:** In its current state, the log system is only intended for debugging -startup errors. +> [!NOTE] +> In its current state, the log system is only intended for debugging startup errors. The `log` object configures the logging. It has the following properties: * `output`: The output to which logs are written. - **NOTE:** Log entries written to the system log are in text format and use - the system timestamp. + > [!NOTE] + > Log entries written to the system log are in text format and use the system timestamp. + + > [!NOTE] + > If `log.format` is set to `adguard_legacy`, output is set to `stderr`. Possible values: @@ -239,6 +242,9 @@ The `log` object configures the logging. It has the following properties: * `format`: Specifies format of the log entries. + > [!NOTE] + > If `log.format` is set to `adguard_legacy`, output is set to `stderr`. + Possible values: * `adguard_legacy`; diff --git a/doc/environment.md b/doc/environment.md index fe65fb7..5c0c0ec 100644 --- a/doc/environment.md +++ b/doc/environment.md @@ -24,6 +24,9 @@ AdGuard DNS Client uses [environment variables][wiki-env] to store some of the c The log destination, must be an absolute path to the file or one of the special values. +> [!NOTE] +> If `LOG_FORMAT` is set to `adguard_legacy`, output is set to `stderr`. + - `syslog` means that the platform-specific system log is used, which is syslog for Linux and Event Log for Windows. > [!NOTE] @@ -49,6 +52,9 @@ This environment variable has priority over [log.output][conf-log-output] field The format for log entries. +> [!NOTE] +> If `LOG_FORMAT` is set to `adguard_legacy`, output is set to `stderr`. + - `adguard_legacy`; - `default`; - `json`; diff --git a/internal/cmd/program.go b/internal/cmd/program.go index f37d4cf..7578c0e 100644 --- a/internal/cmd/program.go +++ b/internal/cmd/program.go @@ -41,13 +41,14 @@ func (prog *program) Start(_ osservice.Service) (err error) { ctx := context.Background() l := prog.log.With(slogutil.KeyPrefix, serviceProgramPrefix) - // Disable the dnsproxy logging for now, unless asked for debug output. + // Disable the dnsproxy logging for now, unless asked for debug output or + // using the "adguard_legacy" format. // // TODO(e.burkov): Use [log/slog] in [dnsproxy] and make it configurable. isVerbose := l.Enabled(ctx, slog.LevelDebug) if isVerbose { log.SetLevel(log.DEBUG) - } else { + } else if _, ok := l.Handler().(*slogutil.AdGuardLegacyHandler); !ok { log.SetLevel(log.OFF) }