logger icon indicating copy to clipboard operation
logger copied to clipboard

Receiving logs into console even with `nothing` set to Logger

Open comatory opened this issue 4 years ago • 1 comments

I do a detection based on application environment to turn off logging completely like this:

_logger = Logger(output: null);
Logger.level = Level.nothing;

Meaning I still create Logger instance so I don't have to put if (env == 'prod') everywhere in my app. I just tried running it locally where I've overriden env detection so the code above is executed however I still see logs flowing into my system console.

Did I somehow misunderstood what Logger.level does? I'm using _logger.d(), _logger.i etc so the levels for each message are set appropriately. I would assume since Level.nothing has value of 6 it's higher that the other ones and it all should be ignored.

comatory avatar Jan 20 '22 15:01 comatory

I think you should be using a LogFilter for this. See for example: https://github.com/leisim/logger/blob/master/lib/src/filters/development_filter.dart

haarts avatar Jun 03 '22 13:06 haarts