feat: loggers should only be added at the top-level entrypoint
Closed this issue · 1 comments
HLasse commented
feat: loggers should only be added at the top-level entrypoint
MartinBernstorff commented
Behaviour: Users only specify one logger at the outermost layer, and then this logger is automatically passed to all child-layers.
This requires a "two-stage init". One init that validates all the core arguments, and another init that passes the loggers down through the layers.
How do we implement this? I think an "SupportsLogger" mixin, which specifies:
-
How to add the logger
-
The logger property, which gets the attribute, or raises an error if it is not specified
- Hmm, if making a dependency-injected tree, it resolves from the bottom up. This means the post_init will be called before the logger has been passed down. Instead, the logger should be set on
set_logger
, so the cascade can be started by the BaselineSchema.
- Hmm, if making a dependency-injected tree, it resolves from the bottom up. This means the post_init will be called before the logger has been passed down. Instead, the logger should be set on
-
Currently, all inheritors of
SupportLoggerMixin
have to be dataclasses. That is a stringent requirement to set! Perhaps we can get around that?- Yep, refactored to remove
-
Update the test .cfgs
-
Add handling of logger on the external layer
- If no logger, initialise a dummylogger, and print a warning that no logger is in use