simc / logger

Small, easy to use and extensible logger which prints beautiful logs.
https://pub.dev/packages/logger
MIT License
1.07k stars 129 forks source link

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

Open comatory opened 2 years ago

comatory commented 2 years ago

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.

haarts commented 2 years ago

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