Skip to content

Commit

Permalink
all: imp adguard_legacy log, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ainar-g committed Jun 20, 2024
1 parent 9457bd9 commit e6617bd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ Option `--version` makes AdGuard DNS Client print out the version of the `AdGuar

## <a href="#conf" id="conf" name="conf">Configuration</a>

### <a href="#conf-file" id="conf-file" name="conf-file">File</a>

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
Expand Down
14 changes: 10 additions & 4 deletions doc/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,19 @@ the following properties:

## <a href="#log" id="log" name="log">Logging</a>

**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:

* <a href="#log-output" id="log-output" name="log-output">`output`</a>:
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:

Expand All @@ -239,6 +242,9 @@ The `log` object configures the logging. It has the following properties:
* <a href="#log-format" id="log-format" name="log-format">`format`</a>:
Specifies format of the log entries.

> [!NOTE]
> If `log.format` is set to `adguard_legacy`, output is set to `stderr`.

Possible values:

* `adguard_legacy`;
Expand Down
6 changes: 6 additions & 0 deletions doc/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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`;
Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit e6617bd

Please sign in to comment.