// TODO: Add standard crate prelude.

mod counter;
mod limiter;
mod macros;

use std::time::Duration;

pub use counter::{Count, CountedEvent, Counter, ProblemCount};
pub use limiter::{rt::install_runtime, RateLim};

/// Re-exports for macros.
#[doc(hidden)]
pub mod x {
    pub use once_cell::sync::Lazy;
    pub use tracing;
}

/// An group of events that an be logged singly or in a summary over a period of time.
pub trait Loggable: 'static + Send {
    /// Log these events immediately, if there is anything to log.
    ///
    /// The `summarizing` argument is the amount of time that this `Loggable``
    /// has been accumulating information.  It is `None` if we are not
    /// rate-limiting this loggable.
    ///
    /// Implementations should return `Active` if they have logged that
    /// some activity happened, and `Dormant` if they had nothing to log, or
    /// if they are logging "I didn't see that problem for a while."
    ///
    ///  After a `Loggable` has been dormant for a while, its timer will be reset.
    fn flush(&mut self, summarizing: Option<Duration>) -> Activity;
}

/// A description of the whether a `Loggable` had something to say.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Activity {
    Active,
    Dormant,
}
