|
1 | 1 | // Take a look at the license at the top of the repository in the LICENSE file. |
2 | 2 |
|
3 | | -use crate::{log as glib_log, translate::*}; |
| 3 | +use crate::{gstr, log as glib_log, log_structured_array, translate::*, LogField}; |
4 | 4 |
|
5 | 5 | // rustdoc-stripper-ignore-next |
6 | 6 | /// Enumeration of the possible formatting behaviours for a |
@@ -143,17 +143,25 @@ impl GlibLogger { |
143 | 143 | ) { |
144 | 144 | let line = line.map(|l| l.to_string()); |
145 | 145 | let line = line.as_deref(); |
146 | | - |
147 | | - crate::log_structured!( |
148 | | - domain.unwrap_or("default"), |
149 | | - GlibLogger::level_to_glib(level), |
150 | | - { |
151 | | - "CODE_FILE" => file.unwrap_or("<unknown file>"); |
152 | | - "CODE_LINE" => line.unwrap_or("<unknown line>"); |
153 | | - "CODE_FUNC" => func.unwrap_or("<unknown module path>"); |
154 | | - "MESSAGE" => message; |
155 | | - } |
156 | | - ); |
| 146 | + let glib_level = GlibLogger::level_to_glib(level); |
| 147 | + let fields = [ |
| 148 | + LogField::new(gstr!("PRIORITY"), glib_level.priority().as_bytes()), |
| 149 | + LogField::new( |
| 150 | + gstr!("CODE_FILE"), |
| 151 | + file.unwrap_or("<unknown file>").as_bytes(), |
| 152 | + ), |
| 153 | + LogField::new( |
| 154 | + gstr!("CODE_LINE"), |
| 155 | + line.unwrap_or("<unknown line>").as_bytes(), |
| 156 | + ), |
| 157 | + LogField::new( |
| 158 | + gstr!("CODE_FUNC"), |
| 159 | + func.unwrap_or("<unknown module path>").as_bytes(), |
| 160 | + ), |
| 161 | + LogField::new(gstr!("MESSAGE"), message.as_bytes()), |
| 162 | + LogField::new(gstr!("GLIB_DOMAIN"), domain.unwrap_or("default").as_bytes()), |
| 163 | + ]; |
| 164 | + log_structured_array(glib_level, &fields); |
157 | 165 | } |
158 | 166 | } |
159 | 167 |
|
|
0 commit comments