Parcourir la source

wallet: limit logfile to 5Mb max

darkfi il y a 1 an
Parent
commit
d0691b3e7d
1 fichiers modifiés avec 4 ajouts et 2 suppressions
  1. 4 2
      bin/darkwallet/src/logger.rs

+ 4 - 2
bin/darkwallet/src/logger.rs

@@ -8,6 +8,8 @@ use simplelog::{
 use std::{thread::sleep, time::Duration};
 
 const LOGS_ENABLED: bool = true;
+// Measured in bytes
+const LOGFILE_MAXSIZE: usize = 5_000_000;
 
 #[cfg(target_os = "android")]
 const LOGFILE_PATH: &str = "/sdcard/Download/darkwallet.log";
@@ -82,8 +84,8 @@ pub fn setup_logging() {
         let logfile_path = expand_path(LOGFILE_PATH).unwrap();
         let log_file = FileRotate::new(
             logfile_path,
-            AppendCount::new(7),
-            ContentLimit::Lines(1000),
+            AppendCount::new(0),
+            ContentLimit::BytesSurpassed(LOGFILE_MAXSIZE),
             Compression::None,
             #[cfg(unix)]
             None,