@@ -38,64 +38,13 @@ macro_rules! ngx_log_debug_http {
3838 }
3939}
4040
41- /// Debug masks for use with ngx_log_debug_mask, these represent the only accepted values for the
42- /// mask.
43- #[ derive( Debug ) ]
44- pub enum DebugMask {
45- /// Aligns to the NGX_LOG_DEBUG_CORE mask.
46- Core ,
47- /// Aligns to the NGX_LOG_DEBUG_ALLOC mask.
48- Alloc ,
49- /// Aligns to the NGX_LOG_DEBUG_MUTEX mask.
50- Mutex ,
51- /// Aligns to the NGX_LOG_DEBUG_EVENT mask.
52- Event ,
53- /// Aligns to the NGX_LOG_DEBUG_HTTP mask.
54- Http ,
55- /// Aligns to the NGX_LOG_DEBUG_MAIL mask.
56- Mail ,
57- /// Aligns to the NGX_LOG_DEBUG_STREAM mask.
58- Stream ,
59- }
60-
61- impl TryFrom < u32 > for DebugMask {
62- type Error = u32 ;
63-
64- fn try_from ( value : u32 ) -> Result < Self , Self :: Error > {
65- match value {
66- crate :: ffi:: NGX_LOG_DEBUG_CORE => Ok ( DebugMask :: Core ) ,
67- crate :: ffi:: NGX_LOG_DEBUG_ALLOC => Ok ( DebugMask :: Alloc ) ,
68- crate :: ffi:: NGX_LOG_DEBUG_MUTEX => Ok ( DebugMask :: Mutex ) ,
69- crate :: ffi:: NGX_LOG_DEBUG_EVENT => Ok ( DebugMask :: Event ) ,
70- crate :: ffi:: NGX_LOG_DEBUG_HTTP => Ok ( DebugMask :: Http ) ,
71- crate :: ffi:: NGX_LOG_DEBUG_MAIL => Ok ( DebugMask :: Mail ) ,
72- crate :: ffi:: NGX_LOG_DEBUG_STREAM => Ok ( DebugMask :: Stream ) ,
73- _ => Err ( 0 ) ,
74- }
75- }
76- }
77-
78- impl From < DebugMask > for u32 {
79- fn from ( value : DebugMask ) -> Self {
80- match value {
81- DebugMask :: Core => crate :: ffi:: NGX_LOG_DEBUG_CORE ,
82- DebugMask :: Alloc => crate :: ffi:: NGX_LOG_DEBUG_ALLOC ,
83- DebugMask :: Mutex => crate :: ffi:: NGX_LOG_DEBUG_MUTEX ,
84- DebugMask :: Event => crate :: ffi:: NGX_LOG_DEBUG_EVENT ,
85- DebugMask :: Http => crate :: ffi:: NGX_LOG_DEBUG_HTTP ,
86- DebugMask :: Mail => crate :: ffi:: NGX_LOG_DEBUG_MAIL ,
87- DebugMask :: Stream => crate :: ffi:: NGX_LOG_DEBUG_STREAM ,
88- }
89- }
90- }
91-
9241/// Log with requested debug mask.
9342///
94- /// **NOTE:** This macro supports `DebugMask::Http` (`NGX_LOG_DEBUG_HTTP`), however, if you have
95- /// access to a Request object via an http handler it can be more convenient and readable to use the
96- /// `ngx_log_debug_http` macro instead.
43+ /// **NOTE:** This macro supports [ `DebugMask::Http`] (`NGX_LOG_DEBUG_HTTP`), however, if you have
44+ /// access to a Request object via an http handler it can be more convenient and readable to use
45+ /// the [ `ngx_log_debug_http`] macro instead.
9746///
98- /// See https://nginx.org/en/docs/dev/development_guide.html#logging for details and available
47+ /// See < https://nginx.org/en/docs/dev/development_guide.html#logging> for details and available
9948/// masks.
10049#[ macro_export]
10150macro_rules! ngx_log_debug_mask {
@@ -178,6 +127,57 @@ macro_rules! ngx_log_debug_mask {
178127 } ) ;
179128}
180129
130+ /// Debug masks for use with [`ngx_log_debug_mask`], these represent the only accepted values for
131+ /// the mask.
132+ #[ derive( Debug ) ]
133+ pub enum DebugMask {
134+ /// Aligns to the NGX_LOG_DEBUG_CORE mask.
135+ Core ,
136+ /// Aligns to the NGX_LOG_DEBUG_ALLOC mask.
137+ Alloc ,
138+ /// Aligns to the NGX_LOG_DEBUG_MUTEX mask.
139+ Mutex ,
140+ /// Aligns to the NGX_LOG_DEBUG_EVENT mask.
141+ Event ,
142+ /// Aligns to the NGX_LOG_DEBUG_HTTP mask.
143+ Http ,
144+ /// Aligns to the NGX_LOG_DEBUG_MAIL mask.
145+ Mail ,
146+ /// Aligns to the NGX_LOG_DEBUG_STREAM mask.
147+ Stream ,
148+ }
149+
150+ impl TryFrom < u32 > for DebugMask {
151+ type Error = u32 ;
152+
153+ fn try_from ( value : u32 ) -> Result < Self , Self :: Error > {
154+ match value {
155+ crate :: ffi:: NGX_LOG_DEBUG_CORE => Ok ( DebugMask :: Core ) ,
156+ crate :: ffi:: NGX_LOG_DEBUG_ALLOC => Ok ( DebugMask :: Alloc ) ,
157+ crate :: ffi:: NGX_LOG_DEBUG_MUTEX => Ok ( DebugMask :: Mutex ) ,
158+ crate :: ffi:: NGX_LOG_DEBUG_EVENT => Ok ( DebugMask :: Event ) ,
159+ crate :: ffi:: NGX_LOG_DEBUG_HTTP => Ok ( DebugMask :: Http ) ,
160+ crate :: ffi:: NGX_LOG_DEBUG_MAIL => Ok ( DebugMask :: Mail ) ,
161+ crate :: ffi:: NGX_LOG_DEBUG_STREAM => Ok ( DebugMask :: Stream ) ,
162+ _ => Err ( 0 ) ,
163+ }
164+ }
165+ }
166+
167+ impl From < DebugMask > for u32 {
168+ fn from ( value : DebugMask ) -> Self {
169+ match value {
170+ DebugMask :: Core => crate :: ffi:: NGX_LOG_DEBUG_CORE ,
171+ DebugMask :: Alloc => crate :: ffi:: NGX_LOG_DEBUG_ALLOC ,
172+ DebugMask :: Mutex => crate :: ffi:: NGX_LOG_DEBUG_MUTEX ,
173+ DebugMask :: Event => crate :: ffi:: NGX_LOG_DEBUG_EVENT ,
174+ DebugMask :: Http => crate :: ffi:: NGX_LOG_DEBUG_HTTP ,
175+ DebugMask :: Mail => crate :: ffi:: NGX_LOG_DEBUG_MAIL ,
176+ DebugMask :: Stream => crate :: ffi:: NGX_LOG_DEBUG_STREAM ,
177+ }
178+ }
179+ }
180+
181181#[ cfg( test) ]
182182mod tests {
183183
0 commit comments