Struct tracing_log::InterestCacheConfig
source · pub struct InterestCacheConfig { /* private fields */ }
interest-cache
and log-tracer
and std
only.Expand description
The interest cache configuration.
Implementations§
source§impl InterestCacheConfig
impl InterestCacheConfig
sourcepub fn with_min_verbosity(self, level: Level) -> Self
pub fn with_min_verbosity(self, level: Level) -> Self
Sets the minimum logging verbosity for which the cache will apply.
The interest for logs with a lower verbosity than specified here will not be cached.
It should be set to the lowest verbosity level for which the majority of the logs in your application are usually disabled.
In normal circumstances with typical logger usage patterns you shouldn’t ever have to change this.
By default this is set to Debug
.
sourcepub fn with_lru_cache_size(self, size: usize) -> Self
pub fn with_lru_cache_size(self, size: usize) -> Self
Sets the number of entries in the LRU cache used to cache interests
for log
records.
The bigger the cache, the more unlikely it will be for the interest in a given callsite to be recalculated, at the expense of extra memory usage per every thread which tries to log events.
Every unique level + target pair consumes a single slot in the cache. Entries will be added to the cache until its size reaches the value configured here, and from then on it will evict the least recently seen level + target pair when adding a new entry.
The ideal value to set here widely depends on how much exactly you’re logging, and how diverse the targets are to which you are logging.
If your application spends a significant amount of time filtering logs which are not getting printed out then increasing this value will most likely help.
Setting this to zero will disable the cache.
By default this is set to 1024.