Compare commits
No commits in common. "6f1714d100d66570c0136c5671ac13b91b422c0b" and "1a920e4e2614bba644f92dd850b638237ec2c08c" have entirely different histories.
6f1714d100
...
1a920e4e26
@ -16,7 +16,7 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from datetime import datetime, timezone
|
||||
|
||||
def clean_old_logs(log_dir, max_age_seconds=86400):
|
||||
now = datetime.now(timezone.utc)
|
||||
|
@ -122,13 +122,13 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
// Log rotation: Remove logs older than MAX_LOG_AGE_DAYS
|
||||
int maxLogAgeDays = config["MAX_LOG_AGE_DAYS"].as<int>();
|
||||
auto now = fs::file_time_type::clock::now();
|
||||
auto now = fs::file_time_type::clock::now(); // Use the same clock as file_time_type
|
||||
|
||||
for (const auto& entry : fs::directory_iterator(LOG_DIR)) {
|
||||
if (entry.is_regular_file()) {
|
||||
auto ftime = fs::last_write_time(entry.path());
|
||||
auto age = std::chrono::duration_cast<std::chrono::hours>(now - ftime).count() / 24;
|
||||
if (age >= maxLogAgeDays) {
|
||||
if (age > maxLogAgeDays) {
|
||||
fs::remove(entry.path());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user