Skip to main content

xet_runtime/config/groups/
log.rs

1use std::time::Duration;
2
3use crate::utils::ByteSize;
4
5crate::config_group!({
6
7    /// The log destination.  By default, logs to the logs/ subdirectory in the huggingface xet cache directory.
8    ///
9    /// If this path exists as a directory or the path ends with a /, then logs will be dumped into to that directory.
10    /// Dy default, logs older than LOG_DIR_MAX_RETENTION_AGE in the directory are deleted, and old logs are deleted to
11    /// keep the total size of files present below LOG_DIR_MAX_SIZE.
12    ///
13    /// If LOG_DEST is given but empty, then logs are dumped to the console.
14    ///
15    /// The default value is None.
16    ///
17    /// Use the environment variable `HF_XET_LOG_DEST` to set this value.
18    ref dest : Option<String> = None;
19
20    /// The format the logs are printed in. If "json", then logs are dumped as json blobs; otherwise they
21    /// are treated as text.  By default logging to files is done in json and console logging is done with text.
22    ///
23    /// The default value is None.
24    ///
25    /// Use the environment variable `HF_XET_LOG_FORMAT` to set this value.
26    ref format : Option<String> = None;
27
28    /// The base name for a log file when logging to a directory.  The timestamp and pid are appended to this name to form the log
29    /// file.
30    ///
31    /// The default value is "xet".
32    ///
33    /// Use the environment variable `HF_XET_LOG_PREFIX` to set this value.
34    ref prefix : String = "xet".to_string();
35
36    /// If given, disable cleaning up old files in the log directory.
37    ///
38    /// The default value is false.
39    ///
40    /// Use the environment variable `HF_XET_LOG_DIR_DISABLE_CLEANUP` to set this value.
41    ref dir_disable_cleanup : bool = false;
42
43    /// If given, prune old log files in the directory to keep the directory size under this many bytes.
44    ///
45    /// Note that the directory may exceed this size as pruning is done only on files without an associated active process
46    /// and older than LOG_DIR_MIN_DELETION_AGE.
47    ///
48    /// The default value is 250mb.
49    ///
50    /// Use the environment variable `HF_XET_LOG_DIR_MAX_SIZE` to set this value.
51    ref dir_max_size: ByteSize = ByteSize::from("250mb");
52
53    /// Do not delete any files younger than this.
54    ///
55    /// The default value is 1day.
56    ///
57    /// Use the environment variable `HF_XET_LOG_DIR_MIN_DELETION_AGE` to set this value.
58    ref dir_min_deletion_age: Duration = Duration::from_secs(24 * 3600); // 1 day
59
60    /// Delete all files older than this.
61    ///
62    /// The default value is 14day.
63    ///
64    /// Use the environment variable `HF_XET_LOG_DIR_MAX_RETENTION_AGE` to set this value.
65    ref dir_max_retention_age: Duration = Duration::from_secs(14 * 24 * 3600); // 2 weeks
66
67});