AdGuardHome/internal/querylog/querylogfile.go

208 lines
4.7 KiB
Go
Raw Normal View History

package querylog
import (
"bytes"
"context"
"encoding/json"
"fmt"
"os"
"time"
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
"github.com/AdguardTeam/golibs/errors"
"github.com/AdguardTeam/golibs/logutil/slogutil"
"github.com/c2h5oh/datasize"
)
// flushLogBuffer flushes the current buffer to file and resets the current
// buffer.
func (l *queryLog) flushLogBuffer(ctx context.Context) (err error) {
Pull request 2020: AG-26236-ring-buffer Squashed commit of the following: commit 4b9cc9ddf52739fc5f918babedc99ac7ac0e2415 Merge: a6259ed57 39aeaf891 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:39:58 2023 +0300 Merge branch 'master' into AG-26236-ring-buffer commit a6259ed5758156e4110ee3ea6a49760d2880ade3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:30:20 2023 +0300 querylog: imp code commit 40f9f7cd5a1cff22bcb858020f2cfa9be8399671 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:11:49 2023 +0300 querylog: fix typo commit 1aabbadcb5fcbe6a95945c5bd1455b956b85a8d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:05:22 2023 +0300 querylog: imp err msg commit 02913d35b43e190e42765823ccfcdd332839e984 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:37:47 2023 +0300 aghalg: imp tests commit 98a7909088d2a65b78afa9fa3113545c94429e65 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:23:10 2023 +0300 all: imp tests commit e147804eeafe89e5020cd917784eef3ff2b310d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 18:49:49 2023 +0300 all: imp code commit 5f21f2f63b7bce89f2bc79c97c7350cd693c956b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 14:39:43 2023 +0300 all: add tests commit 35a45c7dc5d5961f6987da7c69249c56e54e97f5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Oct 2 17:43:09 2023 +0300 all: imp code commit 21e51fcbe411258eaf830825df9d05b7ddcc187a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Sep 29 18:21:00 2023 +0300 all: add ring buffer
2023-10-03 20:50:43 +03:00
defer func() { err = errors.Annotate(err, "flushing log buffer: %w") }()
l.fileFlushLock.Lock()
defer l.fileFlushLock.Unlock()
b, err := l.encodeEntries(ctx)
Pull request 2020: AG-26236-ring-buffer Squashed commit of the following: commit 4b9cc9ddf52739fc5f918babedc99ac7ac0e2415 Merge: a6259ed57 39aeaf891 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:39:58 2023 +0300 Merge branch 'master' into AG-26236-ring-buffer commit a6259ed5758156e4110ee3ea6a49760d2880ade3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:30:20 2023 +0300 querylog: imp code commit 40f9f7cd5a1cff22bcb858020f2cfa9be8399671 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:11:49 2023 +0300 querylog: fix typo commit 1aabbadcb5fcbe6a95945c5bd1455b956b85a8d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:05:22 2023 +0300 querylog: imp err msg commit 02913d35b43e190e42765823ccfcdd332839e984 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:37:47 2023 +0300 aghalg: imp tests commit 98a7909088d2a65b78afa9fa3113545c94429e65 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:23:10 2023 +0300 all: imp tests commit e147804eeafe89e5020cd917784eef3ff2b310d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 18:49:49 2023 +0300 all: imp code commit 5f21f2f63b7bce89f2bc79c97c7350cd693c956b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 14:39:43 2023 +0300 all: add tests commit 35a45c7dc5d5961f6987da7c69249c56e54e97f5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Oct 2 17:43:09 2023 +0300 all: imp code commit 21e51fcbe411258eaf830825df9d05b7ddcc187a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Sep 29 18:21:00 2023 +0300 all: add ring buffer
2023-10-03 20:50:43 +03:00
if err != nil {
// Don't wrap the error since it's informative enough as is.
return err
}
return l.flushToFile(ctx, b)
}
Pull request 2020: AG-26236-ring-buffer Squashed commit of the following: commit 4b9cc9ddf52739fc5f918babedc99ac7ac0e2415 Merge: a6259ed57 39aeaf891 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:39:58 2023 +0300 Merge branch 'master' into AG-26236-ring-buffer commit a6259ed5758156e4110ee3ea6a49760d2880ade3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:30:20 2023 +0300 querylog: imp code commit 40f9f7cd5a1cff22bcb858020f2cfa9be8399671 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:11:49 2023 +0300 querylog: fix typo commit 1aabbadcb5fcbe6a95945c5bd1455b956b85a8d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:05:22 2023 +0300 querylog: imp err msg commit 02913d35b43e190e42765823ccfcdd332839e984 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:37:47 2023 +0300 aghalg: imp tests commit 98a7909088d2a65b78afa9fa3113545c94429e65 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:23:10 2023 +0300 all: imp tests commit e147804eeafe89e5020cd917784eef3ff2b310d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 18:49:49 2023 +0300 all: imp code commit 5f21f2f63b7bce89f2bc79c97c7350cd693c956b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 14:39:43 2023 +0300 all: add tests commit 35a45c7dc5d5961f6987da7c69249c56e54e97f5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Oct 2 17:43:09 2023 +0300 all: imp code commit 21e51fcbe411258eaf830825df9d05b7ddcc187a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Sep 29 18:21:00 2023 +0300 all: add ring buffer
2023-10-03 20:50:43 +03:00
// encodeEntries returns JSON encoded log entries, logs estimated time, clears
// the log buffer.
func (l *queryLog) encodeEntries(ctx context.Context) (b *bytes.Buffer, err error) {
Pull request 2020: AG-26236-ring-buffer Squashed commit of the following: commit 4b9cc9ddf52739fc5f918babedc99ac7ac0e2415 Merge: a6259ed57 39aeaf891 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:39:58 2023 +0300 Merge branch 'master' into AG-26236-ring-buffer commit a6259ed5758156e4110ee3ea6a49760d2880ade3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:30:20 2023 +0300 querylog: imp code commit 40f9f7cd5a1cff22bcb858020f2cfa9be8399671 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:11:49 2023 +0300 querylog: fix typo commit 1aabbadcb5fcbe6a95945c5bd1455b956b85a8d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:05:22 2023 +0300 querylog: imp err msg commit 02913d35b43e190e42765823ccfcdd332839e984 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:37:47 2023 +0300 aghalg: imp tests commit 98a7909088d2a65b78afa9fa3113545c94429e65 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:23:10 2023 +0300 all: imp tests commit e147804eeafe89e5020cd917784eef3ff2b310d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 18:49:49 2023 +0300 all: imp code commit 5f21f2f63b7bce89f2bc79c97c7350cd693c956b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 14:39:43 2023 +0300 all: add tests commit 35a45c7dc5d5961f6987da7c69249c56e54e97f5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Oct 2 17:43:09 2023 +0300 all: imp code commit 21e51fcbe411258eaf830825df9d05b7ddcc187a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Sep 29 18:21:00 2023 +0300 all: add ring buffer
2023-10-03 20:50:43 +03:00
l.bufferLock.Lock()
defer l.bufferLock.Unlock()
Pull request 2020: AG-26236-ring-buffer Squashed commit of the following: commit 4b9cc9ddf52739fc5f918babedc99ac7ac0e2415 Merge: a6259ed57 39aeaf891 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:39:58 2023 +0300 Merge branch 'master' into AG-26236-ring-buffer commit a6259ed5758156e4110ee3ea6a49760d2880ade3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:30:20 2023 +0300 querylog: imp code commit 40f9f7cd5a1cff22bcb858020f2cfa9be8399671 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:11:49 2023 +0300 querylog: fix typo commit 1aabbadcb5fcbe6a95945c5bd1455b956b85a8d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:05:22 2023 +0300 querylog: imp err msg commit 02913d35b43e190e42765823ccfcdd332839e984 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:37:47 2023 +0300 aghalg: imp tests commit 98a7909088d2a65b78afa9fa3113545c94429e65 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:23:10 2023 +0300 all: imp tests commit e147804eeafe89e5020cd917784eef3ff2b310d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 18:49:49 2023 +0300 all: imp code commit 5f21f2f63b7bce89f2bc79c97c7350cd693c956b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 14:39:43 2023 +0300 all: add tests commit 35a45c7dc5d5961f6987da7c69249c56e54e97f5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Oct 2 17:43:09 2023 +0300 all: imp code commit 21e51fcbe411258eaf830825df9d05b7ddcc187a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Sep 29 18:21:00 2023 +0300 all: add ring buffer
2023-10-03 20:50:43 +03:00
bufLen := l.buffer.Len()
if bufLen == 0 {
return nil, errors.Error("nothing to write to a file")
}
start := time.Now()
Pull request 2020: AG-26236-ring-buffer Squashed commit of the following: commit 4b9cc9ddf52739fc5f918babedc99ac7ac0e2415 Merge: a6259ed57 39aeaf891 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:39:58 2023 +0300 Merge branch 'master' into AG-26236-ring-buffer commit a6259ed5758156e4110ee3ea6a49760d2880ade3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:30:20 2023 +0300 querylog: imp code commit 40f9f7cd5a1cff22bcb858020f2cfa9be8399671 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:11:49 2023 +0300 querylog: fix typo commit 1aabbadcb5fcbe6a95945c5bd1455b956b85a8d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:05:22 2023 +0300 querylog: imp err msg commit 02913d35b43e190e42765823ccfcdd332839e984 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:37:47 2023 +0300 aghalg: imp tests commit 98a7909088d2a65b78afa9fa3113545c94429e65 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:23:10 2023 +0300 all: imp tests commit e147804eeafe89e5020cd917784eef3ff2b310d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 18:49:49 2023 +0300 all: imp code commit 5f21f2f63b7bce89f2bc79c97c7350cd693c956b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 14:39:43 2023 +0300 all: add tests commit 35a45c7dc5d5961f6987da7c69249c56e54e97f5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Oct 2 17:43:09 2023 +0300 all: imp code commit 21e51fcbe411258eaf830825df9d05b7ddcc187a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Sep 29 18:21:00 2023 +0300 all: add ring buffer
2023-10-03 20:50:43 +03:00
b = &bytes.Buffer{}
e := json.NewEncoder(b)
l.buffer.Range(func(entry *logEntry) (cont bool) {
err = e.Encode(entry)
Pull request 2020: AG-26236-ring-buffer Squashed commit of the following: commit 4b9cc9ddf52739fc5f918babedc99ac7ac0e2415 Merge: a6259ed57 39aeaf891 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:39:58 2023 +0300 Merge branch 'master' into AG-26236-ring-buffer commit a6259ed5758156e4110ee3ea6a49760d2880ade3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:30:20 2023 +0300 querylog: imp code commit 40f9f7cd5a1cff22bcb858020f2cfa9be8399671 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:11:49 2023 +0300 querylog: fix typo commit 1aabbadcb5fcbe6a95945c5bd1455b956b85a8d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:05:22 2023 +0300 querylog: imp err msg commit 02913d35b43e190e42765823ccfcdd332839e984 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:37:47 2023 +0300 aghalg: imp tests commit 98a7909088d2a65b78afa9fa3113545c94429e65 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:23:10 2023 +0300 all: imp tests commit e147804eeafe89e5020cd917784eef3ff2b310d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 18:49:49 2023 +0300 all: imp code commit 5f21f2f63b7bce89f2bc79c97c7350cd693c956b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 14:39:43 2023 +0300 all: add tests commit 35a45c7dc5d5961f6987da7c69249c56e54e97f5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Oct 2 17:43:09 2023 +0300 all: imp code commit 21e51fcbe411258eaf830825df9d05b7ddcc187a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Sep 29 18:21:00 2023 +0300 all: add ring buffer
2023-10-03 20:50:43 +03:00
return err == nil
})
if err != nil {
// Don't wrap the error since it's informative enough as is.
return nil, err
}
size := b.Len()
elapsed := time.Since(start)
l.logger.DebugContext(
ctx,
"serialized elements via json",
"count", bufLen,
"elapsed", elapsed,
"size", datasize.ByteSize(size),
"size_per_entry", datasize.ByteSize(float64(size)/float64(bufLen)),
"time_per_entry", elapsed/time.Duration(bufLen),
)
Pull request 2020: AG-26236-ring-buffer Squashed commit of the following: commit 4b9cc9ddf52739fc5f918babedc99ac7ac0e2415 Merge: a6259ed57 39aeaf891 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:39:58 2023 +0300 Merge branch 'master' into AG-26236-ring-buffer commit a6259ed5758156e4110ee3ea6a49760d2880ade3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:30:20 2023 +0300 querylog: imp code commit 40f9f7cd5a1cff22bcb858020f2cfa9be8399671 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:11:49 2023 +0300 querylog: fix typo commit 1aabbadcb5fcbe6a95945c5bd1455b956b85a8d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:05:22 2023 +0300 querylog: imp err msg commit 02913d35b43e190e42765823ccfcdd332839e984 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:37:47 2023 +0300 aghalg: imp tests commit 98a7909088d2a65b78afa9fa3113545c94429e65 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:23:10 2023 +0300 all: imp tests commit e147804eeafe89e5020cd917784eef3ff2b310d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 18:49:49 2023 +0300 all: imp code commit 5f21f2f63b7bce89f2bc79c97c7350cd693c956b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 14:39:43 2023 +0300 all: add tests commit 35a45c7dc5d5961f6987da7c69249c56e54e97f5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Oct 2 17:43:09 2023 +0300 all: imp code commit 21e51fcbe411258eaf830825df9d05b7ddcc187a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Sep 29 18:21:00 2023 +0300 all: add ring buffer
2023-10-03 20:50:43 +03:00
l.buffer.Clear()
l.flushPending = false
Pull request 2020: AG-26236-ring-buffer Squashed commit of the following: commit 4b9cc9ddf52739fc5f918babedc99ac7ac0e2415 Merge: a6259ed57 39aeaf891 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:39:58 2023 +0300 Merge branch 'master' into AG-26236-ring-buffer commit a6259ed5758156e4110ee3ea6a49760d2880ade3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:30:20 2023 +0300 querylog: imp code commit 40f9f7cd5a1cff22bcb858020f2cfa9be8399671 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:11:49 2023 +0300 querylog: fix typo commit 1aabbadcb5fcbe6a95945c5bd1455b956b85a8d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:05:22 2023 +0300 querylog: imp err msg commit 02913d35b43e190e42765823ccfcdd332839e984 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:37:47 2023 +0300 aghalg: imp tests commit 98a7909088d2a65b78afa9fa3113545c94429e65 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:23:10 2023 +0300 all: imp tests commit e147804eeafe89e5020cd917784eef3ff2b310d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 18:49:49 2023 +0300 all: imp code commit 5f21f2f63b7bce89f2bc79c97c7350cd693c956b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 14:39:43 2023 +0300 all: add tests commit 35a45c7dc5d5961f6987da7c69249c56e54e97f5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Oct 2 17:43:09 2023 +0300 all: imp code commit 21e51fcbe411258eaf830825df9d05b7ddcc187a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Sep 29 18:21:00 2023 +0300 all: add ring buffer
2023-10-03 20:50:43 +03:00
return b, nil
}
// flushToFile saves the encoded log entries to the query log file.
func (l *queryLog) flushToFile(ctx context.Context, b *bytes.Buffer) (err error) {
l.fileWriteLock.Lock()
defer l.fileWriteLock.Unlock()
Pull request 2020: AG-26236-ring-buffer Squashed commit of the following: commit 4b9cc9ddf52739fc5f918babedc99ac7ac0e2415 Merge: a6259ed57 39aeaf891 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:39:58 2023 +0300 Merge branch 'master' into AG-26236-ring-buffer commit a6259ed5758156e4110ee3ea6a49760d2880ade3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:30:20 2023 +0300 querylog: imp code commit 40f9f7cd5a1cff22bcb858020f2cfa9be8399671 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:11:49 2023 +0300 querylog: fix typo commit 1aabbadcb5fcbe6a95945c5bd1455b956b85a8d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:05:22 2023 +0300 querylog: imp err msg commit 02913d35b43e190e42765823ccfcdd332839e984 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:37:47 2023 +0300 aghalg: imp tests commit 98a7909088d2a65b78afa9fa3113545c94429e65 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:23:10 2023 +0300 all: imp tests commit e147804eeafe89e5020cd917784eef3ff2b310d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 18:49:49 2023 +0300 all: imp code commit 5f21f2f63b7bce89f2bc79c97c7350cd693c956b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 14:39:43 2023 +0300 all: add tests commit 35a45c7dc5d5961f6987da7c69249c56e54e97f5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Oct 2 17:43:09 2023 +0300 all: imp code commit 21e51fcbe411258eaf830825df9d05b7ddcc187a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Sep 29 18:21:00 2023 +0300 all: add ring buffer
2023-10-03 20:50:43 +03:00
filename := l.logFile
Pull request 2312: 7400 Windows permcheck Updates #7400. Squashed commit of the following: commit f50d7c200de545dc6c8ef70b39208f522033fb90 Merge: 47040a14c 37b16bcf7 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Dec 3 18:09:23 2024 +0300 Merge branch 'master' into 7400-chown-permcheck commit 47040a14cd50bf50429f44eba0acdcf736412b61 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Dec 3 14:26:43 2024 +0300 permcheck: fix nil entries commit e1d21c576d75a903b88db3b7beb82348cdcf60c9 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Dec 2 15:37:58 2024 +0300 permcheck: fix nil owner commit b1fc67c4d189293d0aee90c1905f7f387840643b Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Nov 29 18:07:15 2024 +0300 permcheck: imp doc commit 0b6a71326e249f0923e389aa1f6f164b02802a24 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Nov 29 17:16:24 2024 +0300 permcheck: imp code commit 7dfbeda179d0ddb81db54fa4e0dcff189b400215 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Fri Nov 29 14:28:17 2024 +0300 permcheck: imp code commit 3a5b6aced948a2d09fdae823fc986266c9984b3d Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Nov 28 19:21:03 2024 +0300 all: imp code, docs commit c076c9366934303fa8c5909bd13770e367dca72e Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Thu Nov 28 15:14:06 2024 +0300 permcheck: imp code, docs commit 09e4ae1ba12e195454f1db11fa2f5c9e8e170f06 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Nov 27 19:19:11 2024 +0300 all: implement windows permcheck commit b75ed7d4d30e289b8a99e68e6a5e94ab74cf49cb Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Mon Nov 25 18:01:47 2024 +0300 all: revert permissions
2024-12-03 18:26:00 +03:00
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_APPEND, aghos.DefaultPermFile)
if err != nil {
Pull request 2020: AG-26236-ring-buffer Squashed commit of the following: commit 4b9cc9ddf52739fc5f918babedc99ac7ac0e2415 Merge: a6259ed57 39aeaf891 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:39:58 2023 +0300 Merge branch 'master' into AG-26236-ring-buffer commit a6259ed5758156e4110ee3ea6a49760d2880ade3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:30:20 2023 +0300 querylog: imp code commit 40f9f7cd5a1cff22bcb858020f2cfa9be8399671 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:11:49 2023 +0300 querylog: fix typo commit 1aabbadcb5fcbe6a95945c5bd1455b956b85a8d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:05:22 2023 +0300 querylog: imp err msg commit 02913d35b43e190e42765823ccfcdd332839e984 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:37:47 2023 +0300 aghalg: imp tests commit 98a7909088d2a65b78afa9fa3113545c94429e65 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:23:10 2023 +0300 all: imp tests commit e147804eeafe89e5020cd917784eef3ff2b310d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 18:49:49 2023 +0300 all: imp code commit 5f21f2f63b7bce89f2bc79c97c7350cd693c956b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 14:39:43 2023 +0300 all: add tests commit 35a45c7dc5d5961f6987da7c69249c56e54e97f5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Oct 2 17:43:09 2023 +0300 all: imp code commit 21e51fcbe411258eaf830825df9d05b7ddcc187a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Sep 29 18:21:00 2023 +0300 all: add ring buffer
2023-10-03 20:50:43 +03:00
return fmt.Errorf("creating file %q: %w", filename, err)
}
Pull request 2020: AG-26236-ring-buffer Squashed commit of the following: commit 4b9cc9ddf52739fc5f918babedc99ac7ac0e2415 Merge: a6259ed57 39aeaf891 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:39:58 2023 +0300 Merge branch 'master' into AG-26236-ring-buffer commit a6259ed5758156e4110ee3ea6a49760d2880ade3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:30:20 2023 +0300 querylog: imp code commit 40f9f7cd5a1cff22bcb858020f2cfa9be8399671 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:11:49 2023 +0300 querylog: fix typo commit 1aabbadcb5fcbe6a95945c5bd1455b956b85a8d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:05:22 2023 +0300 querylog: imp err msg commit 02913d35b43e190e42765823ccfcdd332839e984 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:37:47 2023 +0300 aghalg: imp tests commit 98a7909088d2a65b78afa9fa3113545c94429e65 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:23:10 2023 +0300 all: imp tests commit e147804eeafe89e5020cd917784eef3ff2b310d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 18:49:49 2023 +0300 all: imp code commit 5f21f2f63b7bce89f2bc79c97c7350cd693c956b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 14:39:43 2023 +0300 all: add tests commit 35a45c7dc5d5961f6987da7c69249c56e54e97f5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Oct 2 17:43:09 2023 +0300 all: imp code commit 21e51fcbe411258eaf830825df9d05b7ddcc187a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Sep 29 18:21:00 2023 +0300 all: add ring buffer
2023-10-03 20:50:43 +03:00
defer func() { err = errors.WithDeferred(err, f.Close()) }()
Pull request 2020: AG-26236-ring-buffer Squashed commit of the following: commit 4b9cc9ddf52739fc5f918babedc99ac7ac0e2415 Merge: a6259ed57 39aeaf891 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:39:58 2023 +0300 Merge branch 'master' into AG-26236-ring-buffer commit a6259ed5758156e4110ee3ea6a49760d2880ade3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:30:20 2023 +0300 querylog: imp code commit 40f9f7cd5a1cff22bcb858020f2cfa9be8399671 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:11:49 2023 +0300 querylog: fix typo commit 1aabbadcb5fcbe6a95945c5bd1455b956b85a8d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:05:22 2023 +0300 querylog: imp err msg commit 02913d35b43e190e42765823ccfcdd332839e984 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:37:47 2023 +0300 aghalg: imp tests commit 98a7909088d2a65b78afa9fa3113545c94429e65 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:23:10 2023 +0300 all: imp tests commit e147804eeafe89e5020cd917784eef3ff2b310d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 18:49:49 2023 +0300 all: imp code commit 5f21f2f63b7bce89f2bc79c97c7350cd693c956b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 14:39:43 2023 +0300 all: add tests commit 35a45c7dc5d5961f6987da7c69249c56e54e97f5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Oct 2 17:43:09 2023 +0300 all: imp code commit 21e51fcbe411258eaf830825df9d05b7ddcc187a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Sep 29 18:21:00 2023 +0300 all: add ring buffer
2023-10-03 20:50:43 +03:00
n, err := f.Write(b.Bytes())
if err != nil {
Pull request 2020: AG-26236-ring-buffer Squashed commit of the following: commit 4b9cc9ddf52739fc5f918babedc99ac7ac0e2415 Merge: a6259ed57 39aeaf891 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:39:58 2023 +0300 Merge branch 'master' into AG-26236-ring-buffer commit a6259ed5758156e4110ee3ea6a49760d2880ade3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:30:20 2023 +0300 querylog: imp code commit 40f9f7cd5a1cff22bcb858020f2cfa9be8399671 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:11:49 2023 +0300 querylog: fix typo commit 1aabbadcb5fcbe6a95945c5bd1455b956b85a8d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 20:05:22 2023 +0300 querylog: imp err msg commit 02913d35b43e190e42765823ccfcdd332839e984 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:37:47 2023 +0300 aghalg: imp tests commit 98a7909088d2a65b78afa9fa3113545c94429e65 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 19:23:10 2023 +0300 all: imp tests commit e147804eeafe89e5020cd917784eef3ff2b310d0 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 18:49:49 2023 +0300 all: imp code commit 5f21f2f63b7bce89f2bc79c97c7350cd693c956b Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Tue Oct 3 14:39:43 2023 +0300 all: add tests commit 35a45c7dc5d5961f6987da7c69249c56e54e97f5 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Oct 2 17:43:09 2023 +0300 all: imp code commit 21e51fcbe411258eaf830825df9d05b7ddcc187a Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Sep 29 18:21:00 2023 +0300 all: add ring buffer
2023-10-03 20:50:43 +03:00
return fmt.Errorf("writing to file %q: %w", filename, err)
}
l.logger.DebugContext(ctx, "flushed to file", "file", filename, "size", datasize.ByteSize(n))
return nil
}
func (l *queryLog) rotate(ctx context.Context) error {
from := l.logFile
to := l.logFile + ".1"
err := os.Rename(from, to)
if err != nil {
Pull request: all: client id support Merge in DNS/adguard-home from 1383-client-id to master Updates #1383. Squashed commit of the following: commit ebe2678bfa9bf651a2cb1e64499b38edcf19a7ad Author: Ildar Kamalov <ik@adguard.com> Date: Wed Jan 27 17:51:59 2021 +0300 - client: check if IP is valid commit 0c330585a170ea149ee75e43dfa65211e057299c Author: Ildar Kamalov <ik@adguard.com> Date: Wed Jan 27 17:07:50 2021 +0300 - client: find clients by client_id commit 71c9593ee35d996846f061e114b7867c3aa3c978 Merge: 9104f161 3e9edd9e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Jan 27 16:09:45 2021 +0300 Merge branch 'master' into 1383-client-id commit 9104f1615d2d462606c52017df25a422df872cea Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Jan 27 13:28:50 2021 +0300 dnsforward: imp tests commit ed47f26e611ade625a2cc2c2f71a291b796bbf8f Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Jan 27 12:39:52 2021 +0300 dnsforward: fix address commit 98b222ba69a5d265f620c180c960d01c84a1fb3b Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 19:50:31 2021 +0300 home: imp code commit 4f3966548a2d8437d0b68207dd108dd1a6cb7d20 Merge: 199fdc05 c215b820 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 19:45:13 2021 +0300 Merge branch 'master' into 1383-client-id commit 199fdc056f8a8be5500584f3aaee32865188aedc Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 19:20:37 2021 +0300 all: imp tests, logging, etc commit 35ff14f4d534251aecb2ea60baba225f3eed8a3e Author: Ildar Kamalov <ik@adguard.com> Date: Tue Jan 26 18:55:19 2021 +0300 + client: remove block button from clients with client_id commit 32991a0b4c56583a02fb5e00bba95d96000bce20 Author: Ildar Kamalov <ik@adguard.com> Date: Tue Jan 26 18:54:25 2021 +0300 + client: add requests count for client_id commit 2d68df4d2eac4a296d7469923e601dad4575c1a1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 15:49:50 2021 +0300 stats: handle client ids commit 4e14ab3590328f93a8cd6e9cbe1665baf74f220b Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 13:45:25 2021 +0300 openapi: fix example commit ca9cf3f744fe197cace2c28ddc5bc68f71dad1f3 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 13:37:10 2021 +0300 openapi: improve clients find api docs commit f79876e550c424558b704bc316a4cd04f25db011 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 13:18:52 2021 +0300 home: accept ids in clients find commit 5b72595122aa0bd64debadfd753ed8a0e0840629 Merge: 607e241f abf8f65f Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Jan 25 18:34:56 2021 +0300 Merge branch 'master' into 1383-client-id commit 607e241f1c339dd6397218f70b8301e3de6a1ee0 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Jan 25 18:30:39 2021 +0300 dnsforward: fix quic commit f046352fef93e46234c2bbe8ae316d21034260e5 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Jan 25 16:53:09 2021 +0300 all: remove wildcard requirement commit 3b679489bae82c54177372be453fe184d8f0bab6 Author: Andrey Meshkov <am@adguard.com> Date: Mon Jan 25 16:02:28 2021 +0300 workDir now supports symlinks commit 0647ab4f113de2223f6949df001f42ecab05c995 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Jan 25 14:59:46 2021 +0300 - client: remove wildcard from domain validation commit b1aec04a4ecadc9d65648ed6d284188fecce01c3 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Jan 25 14:55:39 2021 +0300 + client: add form to download mobileconfig ... and 12 more commits
2021-01-27 18:32:13 +03:00
if errors.Is(err, os.ErrNotExist) {
l.logger.DebugContext(ctx, "no log to rotate")
Pull request: all: client id support Merge in DNS/adguard-home from 1383-client-id to master Updates #1383. Squashed commit of the following: commit ebe2678bfa9bf651a2cb1e64499b38edcf19a7ad Author: Ildar Kamalov <ik@adguard.com> Date: Wed Jan 27 17:51:59 2021 +0300 - client: check if IP is valid commit 0c330585a170ea149ee75e43dfa65211e057299c Author: Ildar Kamalov <ik@adguard.com> Date: Wed Jan 27 17:07:50 2021 +0300 - client: find clients by client_id commit 71c9593ee35d996846f061e114b7867c3aa3c978 Merge: 9104f161 3e9edd9e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Jan 27 16:09:45 2021 +0300 Merge branch 'master' into 1383-client-id commit 9104f1615d2d462606c52017df25a422df872cea Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Jan 27 13:28:50 2021 +0300 dnsforward: imp tests commit ed47f26e611ade625a2cc2c2f71a291b796bbf8f Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Jan 27 12:39:52 2021 +0300 dnsforward: fix address commit 98b222ba69a5d265f620c180c960d01c84a1fb3b Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 19:50:31 2021 +0300 home: imp code commit 4f3966548a2d8437d0b68207dd108dd1a6cb7d20 Merge: 199fdc05 c215b820 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 19:45:13 2021 +0300 Merge branch 'master' into 1383-client-id commit 199fdc056f8a8be5500584f3aaee32865188aedc Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 19:20:37 2021 +0300 all: imp tests, logging, etc commit 35ff14f4d534251aecb2ea60baba225f3eed8a3e Author: Ildar Kamalov <ik@adguard.com> Date: Tue Jan 26 18:55:19 2021 +0300 + client: remove block button from clients with client_id commit 32991a0b4c56583a02fb5e00bba95d96000bce20 Author: Ildar Kamalov <ik@adguard.com> Date: Tue Jan 26 18:54:25 2021 +0300 + client: add requests count for client_id commit 2d68df4d2eac4a296d7469923e601dad4575c1a1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 15:49:50 2021 +0300 stats: handle client ids commit 4e14ab3590328f93a8cd6e9cbe1665baf74f220b Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 13:45:25 2021 +0300 openapi: fix example commit ca9cf3f744fe197cace2c28ddc5bc68f71dad1f3 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 13:37:10 2021 +0300 openapi: improve clients find api docs commit f79876e550c424558b704bc316a4cd04f25db011 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 13:18:52 2021 +0300 home: accept ids in clients find commit 5b72595122aa0bd64debadfd753ed8a0e0840629 Merge: 607e241f abf8f65f Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Jan 25 18:34:56 2021 +0300 Merge branch 'master' into 1383-client-id commit 607e241f1c339dd6397218f70b8301e3de6a1ee0 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Jan 25 18:30:39 2021 +0300 dnsforward: fix quic commit f046352fef93e46234c2bbe8ae316d21034260e5 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Jan 25 16:53:09 2021 +0300 all: remove wildcard requirement commit 3b679489bae82c54177372be453fe184d8f0bab6 Author: Andrey Meshkov <am@adguard.com> Date: Mon Jan 25 16:02:28 2021 +0300 workDir now supports symlinks commit 0647ab4f113de2223f6949df001f42ecab05c995 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Jan 25 14:59:46 2021 +0300 - client: remove wildcard from domain validation commit b1aec04a4ecadc9d65648ed6d284188fecce01c3 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Jan 25 14:55:39 2021 +0300 + client: add form to download mobileconfig ... and 12 more commits
2021-01-27 18:32:13 +03:00
return nil
}
return fmt.Errorf("failed to rename old file: %w", err)
}
l.logger.DebugContext(ctx, "renamed log file", "from", from, "to", to)
Pull request: all: client id support Merge in DNS/adguard-home from 1383-client-id to master Updates #1383. Squashed commit of the following: commit ebe2678bfa9bf651a2cb1e64499b38edcf19a7ad Author: Ildar Kamalov <ik@adguard.com> Date: Wed Jan 27 17:51:59 2021 +0300 - client: check if IP is valid commit 0c330585a170ea149ee75e43dfa65211e057299c Author: Ildar Kamalov <ik@adguard.com> Date: Wed Jan 27 17:07:50 2021 +0300 - client: find clients by client_id commit 71c9593ee35d996846f061e114b7867c3aa3c978 Merge: 9104f161 3e9edd9e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Jan 27 16:09:45 2021 +0300 Merge branch 'master' into 1383-client-id commit 9104f1615d2d462606c52017df25a422df872cea Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Jan 27 13:28:50 2021 +0300 dnsforward: imp tests commit ed47f26e611ade625a2cc2c2f71a291b796bbf8f Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Jan 27 12:39:52 2021 +0300 dnsforward: fix address commit 98b222ba69a5d265f620c180c960d01c84a1fb3b Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 19:50:31 2021 +0300 home: imp code commit 4f3966548a2d8437d0b68207dd108dd1a6cb7d20 Merge: 199fdc05 c215b820 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 19:45:13 2021 +0300 Merge branch 'master' into 1383-client-id commit 199fdc056f8a8be5500584f3aaee32865188aedc Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 19:20:37 2021 +0300 all: imp tests, logging, etc commit 35ff14f4d534251aecb2ea60baba225f3eed8a3e Author: Ildar Kamalov <ik@adguard.com> Date: Tue Jan 26 18:55:19 2021 +0300 + client: remove block button from clients with client_id commit 32991a0b4c56583a02fb5e00bba95d96000bce20 Author: Ildar Kamalov <ik@adguard.com> Date: Tue Jan 26 18:54:25 2021 +0300 + client: add requests count for client_id commit 2d68df4d2eac4a296d7469923e601dad4575c1a1 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 15:49:50 2021 +0300 stats: handle client ids commit 4e14ab3590328f93a8cd6e9cbe1665baf74f220b Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 13:45:25 2021 +0300 openapi: fix example commit ca9cf3f744fe197cace2c28ddc5bc68f71dad1f3 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 13:37:10 2021 +0300 openapi: improve clients find api docs commit f79876e550c424558b704bc316a4cd04f25db011 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Jan 26 13:18:52 2021 +0300 home: accept ids in clients find commit 5b72595122aa0bd64debadfd753ed8a0e0840629 Merge: 607e241f abf8f65f Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Jan 25 18:34:56 2021 +0300 Merge branch 'master' into 1383-client-id commit 607e241f1c339dd6397218f70b8301e3de6a1ee0 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Jan 25 18:30:39 2021 +0300 dnsforward: fix quic commit f046352fef93e46234c2bbe8ae316d21034260e5 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Jan 25 16:53:09 2021 +0300 all: remove wildcard requirement commit 3b679489bae82c54177372be453fe184d8f0bab6 Author: Andrey Meshkov <am@adguard.com> Date: Mon Jan 25 16:02:28 2021 +0300 workDir now supports symlinks commit 0647ab4f113de2223f6949df001f42ecab05c995 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Jan 25 14:59:46 2021 +0300 - client: remove wildcard from domain validation commit b1aec04a4ecadc9d65648ed6d284188fecce01c3 Author: Ildar Kamalov <ik@adguard.com> Date: Mon Jan 25 14:55:39 2021 +0300 + client: add form to download mobileconfig ... and 12 more commits
2021-01-27 18:32:13 +03:00
return nil
}
func (l *queryLog) readFileFirstTimeValue(ctx context.Context) (first time.Time, err error) {
var f *os.File
f, err = os.Open(l.logFile)
- querylog: file rotation didn't work properly; fix entry searching algorithm If AGH is restarted, file rotation timer is reset which can lead to the situation when file rotation procedure is never started. Squashed commit of the following: commit 427ae91a512cd146ebfffad06ed24eb723cb9e7d Merge: 067fac65 e56c746b Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 18:18:46 2020 +0300 Merge remote-tracking branch 'origin/master' into qlogs-rotate commit 067fac65b1a87d499900f4860ffa96ed8208967c Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 15:30:48 2020 +0300 minor commit c2059a15700e5696cb1bb5cd49129c6020d986f4 Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 14:53:07 2020 +0300 improve commit a279438eaf1cf40b820652093fb56d56784de7d8 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 18:49:14 2020 +0300 minor commit 26ac130f139f565de39200e484b3bd4a04afcfcc Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:54:27 2020 +0300 rename commit 0fad7b88dbeadcddd4d77536a18da72f3203ea80 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:05:36 2020 +0300 + TestQLogSeek commit fa6afc6d4dc592b1fef67c4a069ea50fae600a58 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:05:34 2020 +0300 minor commit 11e6ab9131e5c37467e8530a2db95a82bbb0603b Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 19:45:47 2020 +0300 fix tests commit 7cbb89948df0e69b1bae8f8cde1879b5b1c4b1d6 Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 19:29:43 2020 +0300 - querylog: fix entry searching algorithm commit 745d44863d88b321bd7001f24a68620f7ef05819 Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 18:34:14 2020 +0300 - querylog: file rotation didn't work properly If AGH is restarted, file rotation timer is reset which can lead to the situation when file rotation procedure is never started.
2020-09-02 19:42:26 +03:00
if err != nil {
return time.Time{}, err
- querylog: file rotation didn't work properly; fix entry searching algorithm If AGH is restarted, file rotation timer is reset which can lead to the situation when file rotation procedure is never started. Squashed commit of the following: commit 427ae91a512cd146ebfffad06ed24eb723cb9e7d Merge: 067fac65 e56c746b Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 18:18:46 2020 +0300 Merge remote-tracking branch 'origin/master' into qlogs-rotate commit 067fac65b1a87d499900f4860ffa96ed8208967c Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 15:30:48 2020 +0300 minor commit c2059a15700e5696cb1bb5cd49129c6020d986f4 Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 14:53:07 2020 +0300 improve commit a279438eaf1cf40b820652093fb56d56784de7d8 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 18:49:14 2020 +0300 minor commit 26ac130f139f565de39200e484b3bd4a04afcfcc Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:54:27 2020 +0300 rename commit 0fad7b88dbeadcddd4d77536a18da72f3203ea80 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:05:36 2020 +0300 + TestQLogSeek commit fa6afc6d4dc592b1fef67c4a069ea50fae600a58 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:05:34 2020 +0300 minor commit 11e6ab9131e5c37467e8530a2db95a82bbb0603b Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 19:45:47 2020 +0300 fix tests commit 7cbb89948df0e69b1bae8f8cde1879b5b1c4b1d6 Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 19:29:43 2020 +0300 - querylog: fix entry searching algorithm commit 745d44863d88b321bd7001f24a68620f7ef05819 Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 18:34:14 2020 +0300 - querylog: file rotation didn't work properly If AGH is restarted, file rotation timer is reset which can lead to the situation when file rotation procedure is never started.
2020-09-02 19:42:26 +03:00
}
defer func() { err = errors.WithDeferred(err, f.Close()) }()
buf := make([]byte, 512)
var r int
r, err = f.Read(buf)
- querylog: file rotation didn't work properly; fix entry searching algorithm If AGH is restarted, file rotation timer is reset which can lead to the situation when file rotation procedure is never started. Squashed commit of the following: commit 427ae91a512cd146ebfffad06ed24eb723cb9e7d Merge: 067fac65 e56c746b Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 18:18:46 2020 +0300 Merge remote-tracking branch 'origin/master' into qlogs-rotate commit 067fac65b1a87d499900f4860ffa96ed8208967c Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 15:30:48 2020 +0300 minor commit c2059a15700e5696cb1bb5cd49129c6020d986f4 Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 14:53:07 2020 +0300 improve commit a279438eaf1cf40b820652093fb56d56784de7d8 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 18:49:14 2020 +0300 minor commit 26ac130f139f565de39200e484b3bd4a04afcfcc Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:54:27 2020 +0300 rename commit 0fad7b88dbeadcddd4d77536a18da72f3203ea80 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:05:36 2020 +0300 + TestQLogSeek commit fa6afc6d4dc592b1fef67c4a069ea50fae600a58 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:05:34 2020 +0300 minor commit 11e6ab9131e5c37467e8530a2db95a82bbb0603b Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 19:45:47 2020 +0300 fix tests commit 7cbb89948df0e69b1bae8f8cde1879b5b1c4b1d6 Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 19:29:43 2020 +0300 - querylog: fix entry searching algorithm commit 745d44863d88b321bd7001f24a68620f7ef05819 Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 18:34:14 2020 +0300 - querylog: file rotation didn't work properly If AGH is restarted, file rotation timer is reset which can lead to the situation when file rotation procedure is never started.
2020-09-02 19:42:26 +03:00
if err != nil {
return time.Time{}, err
- querylog: file rotation didn't work properly; fix entry searching algorithm If AGH is restarted, file rotation timer is reset which can lead to the situation when file rotation procedure is never started. Squashed commit of the following: commit 427ae91a512cd146ebfffad06ed24eb723cb9e7d Merge: 067fac65 e56c746b Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 18:18:46 2020 +0300 Merge remote-tracking branch 'origin/master' into qlogs-rotate commit 067fac65b1a87d499900f4860ffa96ed8208967c Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 15:30:48 2020 +0300 minor commit c2059a15700e5696cb1bb5cd49129c6020d986f4 Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 14:53:07 2020 +0300 improve commit a279438eaf1cf40b820652093fb56d56784de7d8 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 18:49:14 2020 +0300 minor commit 26ac130f139f565de39200e484b3bd4a04afcfcc Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:54:27 2020 +0300 rename commit 0fad7b88dbeadcddd4d77536a18da72f3203ea80 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:05:36 2020 +0300 + TestQLogSeek commit fa6afc6d4dc592b1fef67c4a069ea50fae600a58 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:05:34 2020 +0300 minor commit 11e6ab9131e5c37467e8530a2db95a82bbb0603b Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 19:45:47 2020 +0300 fix tests commit 7cbb89948df0e69b1bae8f8cde1879b5b1c4b1d6 Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 19:29:43 2020 +0300 - querylog: fix entry searching algorithm commit 745d44863d88b321bd7001f24a68620f7ef05819 Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 18:34:14 2020 +0300 - querylog: file rotation didn't work properly If AGH is restarted, file rotation timer is reset which can lead to the situation when file rotation procedure is never started.
2020-09-02 19:42:26 +03:00
}
val := readJSONValue(string(buf[:r]), `"T":"`)
- querylog: file rotation didn't work properly; fix entry searching algorithm If AGH is restarted, file rotation timer is reset which can lead to the situation when file rotation procedure is never started. Squashed commit of the following: commit 427ae91a512cd146ebfffad06ed24eb723cb9e7d Merge: 067fac65 e56c746b Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 18:18:46 2020 +0300 Merge remote-tracking branch 'origin/master' into qlogs-rotate commit 067fac65b1a87d499900f4860ffa96ed8208967c Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 15:30:48 2020 +0300 minor commit c2059a15700e5696cb1bb5cd49129c6020d986f4 Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 14:53:07 2020 +0300 improve commit a279438eaf1cf40b820652093fb56d56784de7d8 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 18:49:14 2020 +0300 minor commit 26ac130f139f565de39200e484b3bd4a04afcfcc Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:54:27 2020 +0300 rename commit 0fad7b88dbeadcddd4d77536a18da72f3203ea80 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:05:36 2020 +0300 + TestQLogSeek commit fa6afc6d4dc592b1fef67c4a069ea50fae600a58 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:05:34 2020 +0300 minor commit 11e6ab9131e5c37467e8530a2db95a82bbb0603b Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 19:45:47 2020 +0300 fix tests commit 7cbb89948df0e69b1bae8f8cde1879b5b1c4b1d6 Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 19:29:43 2020 +0300 - querylog: fix entry searching algorithm commit 745d44863d88b321bd7001f24a68620f7ef05819 Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 18:34:14 2020 +0300 - querylog: file rotation didn't work properly If AGH is restarted, file rotation timer is reset which can lead to the situation when file rotation procedure is never started.
2020-09-02 19:42:26 +03:00
t, err := time.Parse(time.RFC3339Nano, val)
if err != nil {
return time.Time{}, err
- querylog: file rotation didn't work properly; fix entry searching algorithm If AGH is restarted, file rotation timer is reset which can lead to the situation when file rotation procedure is never started. Squashed commit of the following: commit 427ae91a512cd146ebfffad06ed24eb723cb9e7d Merge: 067fac65 e56c746b Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 18:18:46 2020 +0300 Merge remote-tracking branch 'origin/master' into qlogs-rotate commit 067fac65b1a87d499900f4860ffa96ed8208967c Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 15:30:48 2020 +0300 minor commit c2059a15700e5696cb1bb5cd49129c6020d986f4 Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 14:53:07 2020 +0300 improve commit a279438eaf1cf40b820652093fb56d56784de7d8 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 18:49:14 2020 +0300 minor commit 26ac130f139f565de39200e484b3bd4a04afcfcc Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:54:27 2020 +0300 rename commit 0fad7b88dbeadcddd4d77536a18da72f3203ea80 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:05:36 2020 +0300 + TestQLogSeek commit fa6afc6d4dc592b1fef67c4a069ea50fae600a58 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:05:34 2020 +0300 minor commit 11e6ab9131e5c37467e8530a2db95a82bbb0603b Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 19:45:47 2020 +0300 fix tests commit 7cbb89948df0e69b1bae8f8cde1879b5b1c4b1d6 Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 19:29:43 2020 +0300 - querylog: fix entry searching algorithm commit 745d44863d88b321bd7001f24a68620f7ef05819 Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 18:34:14 2020 +0300 - querylog: file rotation didn't work properly If AGH is restarted, file rotation timer is reset which can lead to the situation when file rotation procedure is never started.
2020-09-02 19:42:26 +03:00
}
l.logger.DebugContext(ctx, "oldest log entry", "entry_time", val)
return t, nil
- querylog: file rotation didn't work properly; fix entry searching algorithm If AGH is restarted, file rotation timer is reset which can lead to the situation when file rotation procedure is never started. Squashed commit of the following: commit 427ae91a512cd146ebfffad06ed24eb723cb9e7d Merge: 067fac65 e56c746b Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 18:18:46 2020 +0300 Merge remote-tracking branch 'origin/master' into qlogs-rotate commit 067fac65b1a87d499900f4860ffa96ed8208967c Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 15:30:48 2020 +0300 minor commit c2059a15700e5696cb1bb5cd49129c6020d986f4 Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 14:53:07 2020 +0300 improve commit a279438eaf1cf40b820652093fb56d56784de7d8 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 18:49:14 2020 +0300 minor commit 26ac130f139f565de39200e484b3bd4a04afcfcc Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:54:27 2020 +0300 rename commit 0fad7b88dbeadcddd4d77536a18da72f3203ea80 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:05:36 2020 +0300 + TestQLogSeek commit fa6afc6d4dc592b1fef67c4a069ea50fae600a58 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:05:34 2020 +0300 minor commit 11e6ab9131e5c37467e8530a2db95a82bbb0603b Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 19:45:47 2020 +0300 fix tests commit 7cbb89948df0e69b1bae8f8cde1879b5b1c4b1d6 Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 19:29:43 2020 +0300 - querylog: fix entry searching algorithm commit 745d44863d88b321bd7001f24a68620f7ef05819 Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 18:34:14 2020 +0300 - querylog: file rotation didn't work properly If AGH is restarted, file rotation timer is reset which can lead to the situation when file rotation procedure is never started.
2020-09-02 19:42:26 +03:00
}
func (l *queryLog) periodicRotate(ctx context.Context) {
defer slogutil.RecoverAndLog(ctx, l.logger)
l.checkAndRotate(ctx)
// rotationCheckIvl is the period of time between checking the need for
// rotating log files. It's smaller of any available rotation interval to
// increase time accuracy.
//
// See https://github.com/AdguardTeam/AdGuardHome/issues/3823.
const rotationCheckIvl = 1 * time.Hour
rotations := time.NewTicker(rotationCheckIvl)
defer rotations.Stop()
for range rotations.C {
l.checkAndRotate(ctx)
}
}
// checkAndRotate rotates log files if those are older than the specified
// rotation interval.
func (l *queryLog) checkAndRotate(ctx context.Context) {
var rotationIvl time.Duration
func() {
l.confMu.RLock()
defer l.confMu.RUnlock()
rotationIvl = l.conf.RotationIvl
}()
Pull request 1731: 4299-stats-ignore Merge in DNS/adguard-home from 4299-stats-ignore to master Updates #1717. Updates #4299. Squashed commit of the following: commit 1d1212d088c944e995deae2fd599eccb0a075033 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Feb 13 17:53:36 2023 +0300 fix changelog commit 5f56852c21d794bd87c13192d3857757be10f9b2 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Feb 13 17:39:02 2023 +0300 add todo; fix data race commit 89b8b16ddf5a43ebf68174cbaf9e8a53365f8cbe Merge: e0a6bb49 ec19a85e Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Feb 10 17:21:38 2023 +0300 Merge branch 'master' into 4299-stats-ignore commit e0a6bb490b651d1cf31589a7f17095fff4cb4dbb Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Feb 10 17:21:06 2023 +0300 interval under mutex commit c569c7bc237f11b23fe47c98a20a1c5cb36751cb Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Feb 10 16:19:35 2023 +0300 fix mutex commit 9374cf0c54dccc2fbfc38765b52c64e1c479137c Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Feb 10 16:03:17 2023 +0300 fix typo commit 1f4fd1e7ab1b3c2f8e9c3d32ef7e4958f99abb47 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Feb 10 15:55:44 2023 +0300 add mutex commit 2148048ce9ad228381cbb51a806c9b9cc21458fd Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Fri Feb 10 12:27:36 2023 +0300 add key check commit a19350977c463f888aea70d0dace26dff0173a65 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 9 18:34:36 2023 +0300 fix changelog commit 23c3b6da162dfd513884b460c265ba4cafeb9727 Merge: 8fccc0b8 b89105e3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 9 13:28:59 2023 +0300 Merge branch 'master' into 4299-stats-ignore commit 8fccc0b8ec670a37e5209d795f35c43dd64afeb3 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Thu Feb 9 13:27:42 2023 +0300 add changelog commit 0416c71742795b2fb8adb0173dcd6a99d9d9c676 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Wed Feb 8 14:31:55 2023 +0300 all: stats ignore
2023-02-13 18:15:33 +03:00
oldest, err := l.readFileFirstTimeValue(ctx)
if err != nil && !errors.Is(err, os.ErrNotExist) {
l.logger.ErrorContext(ctx, "reading oldest record for rotation", slogutil.KeyError, err)
return
}
if rotTime, now := oldest.Add(rotationIvl), time.Now(); rotTime.After(now) {
l.logger.DebugContext(
ctx,
"not rotating",
"now", now.Format(time.RFC3339),
"rotate_time", rotTime.Format(time.RFC3339),
)
return
}
err = l.rotate(ctx)
if err != nil {
l.logger.ErrorContext(ctx, "rotating", slogutil.KeyError, err)
- querylog: file rotation didn't work properly; fix entry searching algorithm If AGH is restarted, file rotation timer is reset which can lead to the situation when file rotation procedure is never started. Squashed commit of the following: commit 427ae91a512cd146ebfffad06ed24eb723cb9e7d Merge: 067fac65 e56c746b Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 18:18:46 2020 +0300 Merge remote-tracking branch 'origin/master' into qlogs-rotate commit 067fac65b1a87d499900f4860ffa96ed8208967c Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 15:30:48 2020 +0300 minor commit c2059a15700e5696cb1bb5cd49129c6020d986f4 Author: Simon Zolin <s.zolin@adguard.com> Date: Wed Sep 2 14:53:07 2020 +0300 improve commit a279438eaf1cf40b820652093fb56d56784de7d8 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 18:49:14 2020 +0300 minor commit 26ac130f139f565de39200e484b3bd4a04afcfcc Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:54:27 2020 +0300 rename commit 0fad7b88dbeadcddd4d77536a18da72f3203ea80 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:05:36 2020 +0300 + TestQLogSeek commit fa6afc6d4dc592b1fef67c4a069ea50fae600a58 Author: Simon Zolin <s.zolin@adguard.com> Date: Tue Sep 1 13:05:34 2020 +0300 minor commit 11e6ab9131e5c37467e8530a2db95a82bbb0603b Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 19:45:47 2020 +0300 fix tests commit 7cbb89948df0e69b1bae8f8cde1879b5b1c4b1d6 Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 19:29:43 2020 +0300 - querylog: fix entry searching algorithm commit 745d44863d88b321bd7001f24a68620f7ef05819 Author: Simon Zolin <s.zolin@adguard.com> Date: Mon Aug 31 18:34:14 2020 +0300 - querylog: file rotation didn't work properly If AGH is restarted, file rotation timer is reset which can lead to the situation when file rotation procedure is never started.
2020-09-02 19:42:26 +03:00
return
}
l.logger.DebugContext(ctx, "rotated successfully")
}