logging icon indicating copy to clipboard operation
logging copied to clipboard

Support finer grained filtering and lazy evaluation

Open venkatd opened this issue 3 years ago • 0 comments

I have many scenarios where I would like to only turn on a few loggers based and setup custom filtering based on some configuration.

For example, I may just want to filter by API calls and Keyboard shortcuts. The LogLevel system isn't fine grained enough to support this. Right now the filter is handled here in the Logger:

bool isLoggable(Level value) => (value >= level);

One proposal would be to introduce an interface called LogFilter. It would look like:

abstract class LogFilter {
  bool isLoggable(LogRecord record);
}

Then, we could update the signature to:

class Level implements Comparable<Level>, LogFilter {
  // ...
  @override
  bool isLoggable(LogRecord record) => this >= record.level;
  // ...
}

Just a rough idea. Any impact this would have on the current logging implementation?

venkatd avatar May 16 '21 18:05 venkatd