File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,10 @@ impl AndroidLogger {
113
113
config : OnceCell :: from ( config) ,
114
114
}
115
115
}
116
+
117
+ fn config ( & self ) -> & Config {
118
+ self . config . get_or_init ( Config :: default)
119
+ }
116
120
}
117
121
118
122
static ANDROID_LOGGER : OnceCell < AndroidLogger > = OnceCell :: new ( ) ;
@@ -130,13 +134,21 @@ impl Default for AndroidLogger {
130
134
}
131
135
132
136
impl Log for AndroidLogger {
133
- fn enabled ( & self , _: & Metadata ) -> bool {
134
- true
137
+ fn enabled ( & self , metadata : & Metadata ) -> bool {
138
+ let config = self . config ( ) ;
139
+ // todo: consider __android_log_is_loggable.
140
+ Some ( metadata. level ( ) ) >= config. log_level
135
141
}
136
142
137
143
fn log ( & self , record : & Record ) {
138
- let config = self . config . get_or_init ( Config :: default) ;
144
+ let config = self . config ( ) ;
145
+
146
+ if !self . enabled ( record. metadata ( ) ) {
147
+ return ;
148
+ }
139
149
150
+ // this also checks the level, but only if a filter was
151
+ // installed.
140
152
if !config. filter_matches ( record) {
141
153
return ;
142
154
}
You can’t perform that action at this time.
0 commit comments