@@ -87,7 +87,7 @@ pub fn install_message_handler(logger: extern "C" fn(QtMsgType, &QMessageLogCont
87
87
///
88
88
/// [Level]: https://docs.rs/log/0.4.10/log/enum.Level.html
89
89
/// [`QtMsgType`]: https://doc.qt.io/qt-5/qtglobal.html#QtMsgType-enum
90
- pub fn map_level ( lvl : & QtMsgType ) -> Level {
90
+ pub fn map_level ( lvl : QtMsgType ) -> Level {
91
91
match lvl {
92
92
QtDebugMsg => Level :: Debug ,
93
93
QtInfoMsg => Level :: Info ,
@@ -120,14 +120,32 @@ pub fn unmap_level(lvl: Level) -> QtMsgType {
120
120
}
121
121
}
122
122
123
+ impl From < QtMsgType > for Level {
124
+ /// Delegates to [default][] mapping algorithm.
125
+ ///
126
+ /// [default]: ./fn.map_level.html
127
+ fn from ( lvl : QtMsgType ) -> Self {
128
+ map_level ( lvl)
129
+ }
130
+ }
131
+
132
+ impl From < Level > for QtMsgType {
133
+ /// Delegates to [default][] mapping algorithm.
134
+ ///
135
+ /// [default]: ./fn.unmap_level.html
136
+ fn from ( lvl : Level ) -> Self {
137
+ unmap_level ( lvl)
138
+ }
139
+ }
140
+
123
141
// Logging middleware, pass-though, or just proxy function.
124
142
// It is called from Qt code, then it converts Qt logging data
125
143
// into Rust logging facade's log::Record object, and sends it
126
144
// to the currently active logger.
127
145
extern "C" fn log_capture ( msg_type : QtMsgType ,
128
146
context : & QMessageLogContext ,
129
147
message : & QString ) {
130
- let level = map_level ( & msg_type) ;
148
+ let level = msg_type. into ( ) ;
131
149
let target = match context. category ( ) {
132
150
"" => "default" ,
133
151
x => x,
@@ -165,7 +183,7 @@ extern "C" fn log_capture(msg_type: QtMsgType,
165
183
/// [Rust logging facade][log].
166
184
///
167
185
/// Most metadata from Qt logging context is retained and passed to [`log::Record`][].
168
- /// Logging levels are mapped with [this ][map_level] algorithm.
186
+ /// Logging levels are mapped with the [default ][map_level] algorithm.
169
187
///
170
188
/// This function may be called more than once.
171
189
///
0 commit comments