Closed peteristhegreat closed 4 years ago
Hmmm, yeah, I think this would fit with the overall design workflow. I might need to play with a final prototype, but that seems like a mostly reasonable solution. I'll note that a simpler solution might be to just add a recursive
flag to setrecord!
which should be as simple as:
function setrecord!(logger, rec; recursive=false)
logger.record = rec
recursive && setrecord!.(getchildren(logger.name), rec; recursive=recursive)
end
This would be a bit more explicit and wouldn't change the default behaviour while also making it easy to change the default record type through all or part of the tree.
But would that still require a strict ordering of when you call setrecord!
to be set after the children loggers are registered, otherwise the children loggers won't pick up the changed record?
That's true, but generally you should be loading all the loggers (by loading the packages that register them) first and then performing any application level configuration last (e.g., adding handlers, setting log levels, setting the record type).
I am following the
conclusion.md
example, and having to callsetrecord!()
after each call togetlogger
seems like it isn't hierarchical. I propose this change inloggers.jl
:Then it would have a cascading effect of any loggers registered after a root or parent logger is set up, would inherit the record type specified.
This may have some ordering issues if a root logger is setup after a more specific logger is made. Maybe a root or parent logger, upon registering should push this setting down to its children that are still on default.
Does this fit in with the design of Memento? Should I make a pull request?