openthread/ot/types/
log_region.rs1use crate::prelude_internal::*;
6use diagnostics_log::Severity;
7use fidl_fuchsia_lowpan_thread::DetailedLoggingLevel;
8
9#[derive(Debug, Copy, Clone, Eq, Ord, PartialOrd, PartialEq, num_derive::FromPrimitive)]
12#[allow(missing_docs)]
13pub enum LogRegion {
14 Api = OT_LOG_REGION_API as isize,
15 Mle = OT_LOG_REGION_MLE as isize,
16 Arp = OT_LOG_REGION_ARP as isize,
17 NetData = OT_LOG_REGION_NET_DATA as isize,
18 Icmp = OT_LOG_REGION_ICMP as isize,
19 Ip6 = OT_LOG_REGION_IP6 as isize,
20 Tcp = OT_LOG_REGION_TCP as isize,
21 Mac = OT_LOG_REGION_MAC as isize,
22 Mem = OT_LOG_REGION_MEM as isize,
23 Ncp = OT_LOG_REGION_NCP as isize,
24 MeshCop = OT_LOG_REGION_MESH_COP as isize,
25 NetDiag = OT_LOG_REGION_NET_DIAG as isize,
26 Platform = OT_LOG_REGION_PLATFORM as isize,
27 Coap = OT_LOG_REGION_COAP as isize,
28 Cli = OT_LOG_REGION_CLI as isize,
29 Core = OT_LOG_REGION_CORE as isize,
30 Util = OT_LOG_REGION_UTIL as isize,
31 Bbr = OT_LOG_REGION_BBR as isize,
32 Mlr = OT_LOG_REGION_MLR as isize,
33 Dua = OT_LOG_REGION_DUA as isize,
34 Br = OT_LOG_REGION_BR as isize,
35 Srp = OT_LOG_REGION_SRP as isize,
36 Dns = OT_LOG_REGION_DNS as isize,
37}
38
39impl From<otLogRegion> for LogRegion {
40 fn from(x: otLogRegion) -> Self {
41 use num::FromPrimitive;
42 Self::from_u64(x as u64).unwrap_or_else(|| panic!("Unknown otLogRegion value: {x}"))
43 }
44}
45
46impl From<LogRegion> for otLogRegion {
47 fn from(x: LogRegion) -> Self {
48 x as otLogRegion
49 }
50}
51
52#[derive(Debug, Copy, Clone, Eq, Ord, PartialOrd, PartialEq, num_derive::FromPrimitive)]
55#[allow(missing_docs)]
56pub enum LogLevel {
57 Crit = OT_LOG_LEVEL_CRIT as isize,
58 Warn = OT_LOG_LEVEL_WARN as isize,
59 Note = OT_LOG_LEVEL_NOTE as isize,
60 Info = OT_LOG_LEVEL_INFO as isize,
61 Debg = OT_LOG_LEVEL_DEBG as isize,
62 None = OT_LOG_LEVEL_NONE as isize,
63}
64
65impl From<otLogLevel> for LogLevel {
66 fn from(x: otLogLevel) -> Self {
67 use num::FromPrimitive;
68 Self::from_u64(x as u64).unwrap_or_else(|| panic!("Unknown otLogLevel value: {x}"))
69 }
70}
71
72impl From<LogLevel> for otLogLevel {
73 fn from(x: LogLevel) -> Self {
74 x as otLogLevel
75 }
76}
77
78impl From<DetailedLoggingLevel> for LogLevel {
79 fn from(x: DetailedLoggingLevel) -> Self {
80 match x {
81 DetailedLoggingLevel::LowpanLogEmerg
82 | DetailedLoggingLevel::LowpanLogAlert
83 | DetailedLoggingLevel::LowpanLogCrit => LogLevel::Crit,
84 DetailedLoggingLevel::LowpanLogErr | DetailedLoggingLevel::LowpanLogWarning => {
85 LogLevel::Warn
86 }
87 DetailedLoggingLevel::LowpanLogNotice => LogLevel::Note,
88 DetailedLoggingLevel::LowpanLogInfo => LogLevel::Info,
89 DetailedLoggingLevel::LowpanLogDebug => LogLevel::Debg,
90 _ => LogLevel::None,
91 }
92 }
93}
94
95impl From<LogLevel> for DetailedLoggingLevel {
96 fn from(x: LogLevel) -> Self {
97 match x {
98 LogLevel::Crit => DetailedLoggingLevel::LowpanLogCrit,
99 LogLevel::Warn => DetailedLoggingLevel::LowpanLogWarning,
100 LogLevel::Note => DetailedLoggingLevel::LowpanLogNotice,
101 LogLevel::Info => DetailedLoggingLevel::LowpanLogInfo,
102 LogLevel::Debg => DetailedLoggingLevel::LowpanLogDebug,
103 _ => DetailedLoggingLevel::LowpanLogUnspecified,
104 }
105 }
106}
107
108impl From<LogLevel> for Severity {
109 fn from(x: LogLevel) -> Self {
110 match x {
111 LogLevel::Crit => Severity::Fatal,
112 LogLevel::Warn => Severity::Warn,
113 LogLevel::Note => Severity::Info,
114 LogLevel::Info => Severity::Info,
115 LogLevel::Debg => Severity::Debug,
116 _ => Severity::Info,
117 }
118 }
119}