1 post tagged “flex logging”
The built in Flex logging package (mx.logging.*) provides a "filters" property for logging targets that allows developers to dictate which classes' logging messages get logged by each target. However, this is an "inclusive" filter. What I mean by that is that this filter tells you what does get logged. There is no support for an "exclusive" filter which would allow developers to specify certain classes to ignore logging messages from. I can see the benefits of an inclusive filter, but for a project the size of eBay Desktop we really need an exclusive filter so we can easily see logging messages for the entire app except for areas we aren't currently interested in. Its sometimes more important to filter out than to filter in.
It turns out that adding an exclusive filter to Flex's logging package is fairly simple. All you need to do is modify the base target interface, ILoggingTarget, to have an additional array of classes to ignore. Then you modify the Log class so that anytime it wants to add a logger to a target it checks to see that the logger's category is both included in the target's filter array and not excluded by the exclusion array. If not then the logger is not added to the target. This amounts to about five lines of code between the addTarget and getLogger functions of Log.
I've subclassed the core logging classes (Log and ILoggingTarget) as well as some of the base target classes (AbstractTarget, LineFormattedTarget, TraceTarget) to include exclusion filtering. You can download a zip here.