UberLogger
UberLogger copied to clipboard
Rough implementation of channel filters 'Channel' object.
Wrote this on a plane after drinking gin, so needs scrutiny.
@Kalmalyzer @astruyk feel free to pull this apart. :)
Also, I'm thinking:
- Do Filters really need to be IFilter? Why not a simple delegate? Would cut down on boiler plate code.
- The inconsistent namespaces are beginning to annoy me. Would it be awful if I refactored everything into an UberLogger namespace, and simplified some of the class names? Would break existing code, which could be annoying for people...
Thanks for making an example implementation! I was swamped with other things at work so it took some time until I could give this a look.
This setup makes sense to me by and large. I have one primary concern and that has to do with naming:
WigWamChannel = new UberLoggerChannel("WigWam", new List<UberLogger.IFilter>() { new UberLogger.FilterWarnings() });
A "Filter" is something that filters things - some things are let through, other things are stopped. Some filters are particular in that they let certain things through - other filters are particular in that they stop certain things. So what does "UberLogger.FilterWarnings" mean? Does it mean, "stop warnings" or does it mean "pass through warnings and stop everything else"? I prefer naming which makes that explicit. Example would be naming these as "StopWarnings" or "MuteWarnings", or "SuppressWarnings" (my personal preference). I'm not 100% happy with those either but I prefer any of those over "FilterWarnings".
The config line is pretty long too. I think it would be good to provide a couple of static lists with names like "SuppressMessages", "SuppressMessagesAndWarnings", "SuppressAll" which then contain appropriate filtering operations. Muting a channel entirely can then be done via:
WigWamChannel = new UberLoggerChannel("WigWam", UberLogger.SuppressAll);
so this would make the common muting options as easy to use as enums.
With regards to IFilter interface vs delegate, I think it would be preferable to have it be a delegate instead of an interface. I set it up as an interface primarily because I wasn't familiar enough with delegates at that time.
Finally, namespaces. Yes, I think this is a good time to move it all into a namespace, existing users be damned :)