Add log_file_latest

This commit is contained in:
Frank Denis 2020-06-08 22:31:03 +02:00
parent 9f9318701f
commit 8945cb1b90
3 changed files with 10 additions and 0 deletions

View File

@ -24,6 +24,8 @@ forced to use TCP.
- The `ct` parameter has been removed from DoH queries, as Google doesn't - The `ct` parameter has been removed from DoH queries, as Google doesn't
require it any more. require it any more.
- Service installation is now supported on FreeBSD. - Service installation is now supported on FreeBSD.
- When stored into a file, service logs now only contain data from the most
recent launch. This can be changed with the new `log_file_latest` option.
* Version 2.0.42 * Version 2.0.42
- The current versions of the `dnsdist` load balancer (presumably used - The current versions of the `dnsdist` load balancer (presumably used

View File

@ -30,6 +30,7 @@ const (
type Config struct { type Config struct {
LogLevel int `toml:"log_level"` LogLevel int `toml:"log_level"`
LogFile *string `toml:"log_file"` LogFile *string `toml:"log_file"`
LogFileLatest bool `toml:"log_file_latest"`
UseSyslog bool `toml:"use_syslog"` UseSyslog bool `toml:"use_syslog"`
ServerNames []string `toml:"server_names"` ServerNames []string `toml:"server_names"`
DisabledServerNames []string `toml:"disabled_server_names"` DisabledServerNames []string `toml:"disabled_server_names"`
@ -100,6 +101,7 @@ type Config struct {
func newConfig() Config { func newConfig() Config {
return Config{ return Config{
LogLevel: int(dlog.LogLevel()), LogLevel: int(dlog.LogLevel()),
LogFileLatest: true,
ListenAddresses: []string{"127.0.0.1:53"}, ListenAddresses: []string{"127.0.0.1:53"},
LocalDoH: LocalDoHConfig{Path: "/dns-query"}, LocalDoH: LocalDoHConfig{Path: "/dns-query"},
Timeout: 5000, Timeout: 5000,
@ -290,6 +292,7 @@ func ConfigLoad(proxy *Proxy, flags *ConfigFlags) error {
if dlog.LogLevel() <= dlog.SeverityDebug && os.Getenv("DEBUG") == "" { if dlog.LogLevel() <= dlog.SeverityDebug && os.Getenv("DEBUG") == "" {
dlog.SetLogLevel(dlog.SeverityInfo) dlog.SetLogLevel(dlog.SeverityInfo)
} }
dlog.TruncateLogFile(config.LogFileLatest)
if config.UseSyslog { if config.UseSyslog {
dlog.UseSyslog(true) dlog.UseSyslog(true)
} else if config.LogFile != nil { } else if config.LogFile != nil {

View File

@ -149,6 +149,11 @@ keepalive = 30
# log_file = 'dnscrypt-proxy.log' # log_file = 'dnscrypt-proxy.log'
## When using a log file, only keep logs from the most recent launch.
# log_file_latest = true
## Use the system logger (syslog on Unix, Event Log on Windows) ## Use the system logger (syslog on Unix, Event Log on Windows)
# use_syslog = true # use_syslog = true