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")]
11#[derive(Default)]
12pub enum Level {
13    Error,
14    Warn,
15    #[default]
16    Info,
17    Debug,
18    Trace,
19    Critical,
20}
21
22impl From<tracing::Level> for Level {
23    fn from(level: tracing::Level) -> Self {
24        match level {
25            tracing::Level::ERROR => Self::Error,
26            tracing::Level::WARN => Self::Warn,
27            tracing::Level::INFO => Self::Info,
28            tracing::Level::DEBUG => Self::Debug,
29            tracing::Level::TRACE => Self::Trace,
30        }
31    }
32}