aether/
log.rs

1use crate::{endpoint::EndpointExt, EndpointSuper, LOGGER};
2
3/// Log entry.
4pub struct LogEntry<'a, EP> {
5    /// The time the log was recorded. See [`chrono::DateTime`] for more details.
6    pub time: chrono::DateTime<chrono::Utc>,
7    /// Specifies which endpoint this log was reported to.
8    pub endpoint: &'a EP,
9    /// The message that was logged.
10    pub text: &'a str,
11}
12
13#[doc(hidden)]
14pub fn impl_log<EP: EndpointSuper + std::hash::Hash + 'static>(endpoint: EP, message: String) {
15    let output = endpoint.fmt_message(message);
16    let mut guard = LOGGER.lock().unwrap();
17    let logger = guard.as_mut().expect("Uninitialized logger. Did you forget to call `aether::init` or did you drop the `KeepAlive` object early?");
18    logger.log(endpoint.endpoint_hash(), output);
19}