Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Improve log filter predicates #364
In the logging framework streams and filters have nice APIs to create/update/remove them. Predicate functions in filters have no such API, and there are two main difficulties in using them in practice:
(1) It's tedious to write code that is aware of any already existing predicates on a filter. You basically have to check whether the filter has a predicate member, and if so, try to chain it to a new predicate. It's also easy to forget to do this, and in turn blow away an existing predicate.
(2) Predicate functions only receive the log record they decide on, and no other state. This makes it harder to write stateful predicates. (Others have already pointed out that closures would also be a nice way to handle this.)
So it would be nice to structure this more, for example by having a management API for predicates that properly supports multiple predicates and how to chain them. I also like the idea of a state pointer for the predicates themselves. (I believe we've recently also touched the possibility of optional function arguments / overloading function signatures.)