wasmcloud_core/
logging.rs

1//! Reusable types related to links on wasmCloud lattices
2//!
3//! NOTE: In the future, generated types to enable easy interoperation with [wasi:logging][wasi-logging] should live here.
4//!
5//! [wasi-logging]: <https://github.com/WebAssembly/wasi-logging>
6
7use serde::{Deserialize, Serialize};
8
9#[derive(Clone, Debug, Deserialize, Serialize)]
10#[serde(rename_all = "lowercase")]
11pub enum Level {
12    Error,
13    Warn,
14    Info,
15    Debug,
16    Trace,
17    Critical,
18}
19
20impl From<tracing::Level> for Level {
21    fn from(level: tracing::Level) -> Self {
22        match level {
23            tracing::Level::ERROR => Self::Error,
24            tracing::Level::WARN => Self::Warn,
25            tracing::Level::INFO => Self::Info,
26            tracing::Level::DEBUG => Self::Debug,
27            tracing::Level::TRACE => Self::Trace,
28        }
29    }
30}
31
32impl Default for Level {
33    fn default() -> Self {
34        Self::Info
35    }
36}