-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Very WIP: Composable log filters #22
base: master
Are you sure you want to change the base?
Conversation
This is interesting. So, Somewhat fun fact is, like transducers (which are "reducing function transforms"), lxf = LogLevelFilter(Error) ∘ MaxLogFilter()
global_logger(lxf(global_logger())) first filters based on the log level and then looks up/stores the global_logger() |> MaxLogFilter() |> LogLevelFilter(Error) |> global_logger
# log event goes right to left I think one catch might be that |
Very interesting, thanks so much for the thoughts. It's great fun to finally have a proper design discussion about this and related issues (here, in LoggingExtras and in Base).
True. I think I originally named them this way in an attempt to avoid being overly vague. (I wasn't sure what a filter-or-transformer should be called). But yes we could probably do better. I wonder what the
Ok this is interesting. It's a bit of a conundrum because I think the fact that this "seems surprising" and needs to be explained in transducer tutorials is a sign that users would also get confused by it here. In fact I think I originally implemented the opposite here by explicitly implementing |
It was interesting to realize sink-oriented-ness of the loggers is very close the push-based approach of transducers. I guess reducing function is kind of a sink after all. I agree that source-oriented API is more intuitive to use. My current thinking is that there is nothing wrong about source-oriented interface (e.g., iterator) as a high-level/surface API. You can always convert sink/source-oriented APIs back and forth as long as there is "adjoint" relationship (this realization led me to this PR JuliaLang/julia#33526 that suggests to convert iterator transforms to transducers just before
Maybe flipping the order is OK, as long as you don't provide the call overload. I think this would mean to expose filters as "message source transforms" which are the adjoint of "logger (= message sink) transforms." Intuitively, it's just something like |
Oh, very interesting. Nice PR! |
It strikes me that the current design of
AbstractLogger
is very sink-centric; every logger is a sink, and one cannot pass around log filter pipelines as standalone objects. There seems to be a very close analogy with iterators which are very source-centric (one can wrap an iterator-filter around an source iterator, but not naturally compose several iterator filters together).For iterators, many problems of composition and efficiency are elegantly solved by moving to transducers. Can we benefit from many of the same ideas here?
@tkf @oxinabox — I thought I'd write a quick note here to let you know a slightly different direction I've considered for log routing. It's likely trying to solve the same problems as
LoggingExtras
, but take a bit of a different tack. The code here is just a quick WIP from a while back and I doubt it takes the ideas from transducers very seriously, so take it FWIW.Largely, I'd just like to stimulate the discussion a bit :-)