Closed matanlurey closed 4 years ago
This is related to hierarchicalLoggingEnabled. If the detached logger isn't a child of the root logger and hierarchicalLoggingEnabled = false then it will never reach the detached logger. Which can be a little confusing.
For example this logger cannot log:
final logger = Logger.detached('DetachedLogger')..level = Level.ALL..onRecord.listen((rec) { print('${rec.level.name}: ${rec.time}: ${rec.message}'); }); logger.info('test');
Error comes from logger.dart line 183 trying to use the root logger (which has a null controller) if hierarchicalLoggingEnabled is false
Why is this closed?
Logger.detached
that explains this. Logger.detached
purports to be "not a part of the global hierarchical loggers structure", so it doesn't make sense to me that it should be affected by hierarchicalLoggingEnabled
.Logger.detached
has if it requires hierarchicalLoggingEnabled = true
. That defeats the point of why I want to use Logger.detached
.Maybe @astashov can comment on the intent of how Logger.detached
is supposed to be used.
Anyway, if we can agree that this should be fixed, I could take it on. I think the level
getter and setter also should be adjusted.
It would be nice to document how to catch messages :-/