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 {
113113 config : OnceCell :: from ( config) ,
114114 }
115115 }
116+
117+ fn config ( & self ) -> & Config {
118+ self . config . get_or_init ( Config :: default)
119+ }
116120}
117121
118122static ANDROID_LOGGER : OnceCell < AndroidLogger > = OnceCell :: new ( ) ;
@@ -130,13 +134,21 @@ impl Default for AndroidLogger {
130134}
131135
132136impl 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
135141 }
136142
137143 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+ }
139149
150+ // this also checks the level, but only if a filter was
151+ // installed.
140152 if !config. filter_matches ( record) {
141153 return ;
142154 }
You can’t perform that action at this time.
0 commit comments