Skip to content

Logger.detached does not fire onRecord messages #434

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

Closed
matanlurey opened this issue Aug 21, 2017 · 3 comments · Fixed by dart-archive/logging#71
Closed

Logger.detached does not fire onRecord messages #434

matanlurey opened this issue Aug 21, 2017 · 3 comments · Fixed by dart-archive/logging#71

Comments

@matanlurey
Copy link
Contributor

It would be nice to document how to catch messages :-/

@java-james
Copy link

java-james commented May 7, 2019

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

@jamesderlin
Copy link
Contributor

Why is this closed?

  1. I don't see any documentation for 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.
  2. I'm confused what purpose Logger.detached has if it requires hierarchicalLoggingEnabled = true. That defeats the point of why I want to use Logger.detached.

@jamesderlin
Copy link
Contributor

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.

@natebosch natebosch reopened this Jan 10, 2020
jakemac53 referenced this issue in dart-archive/logging Jan 15, 2020
)

Previously detached Loggers could log messages only if
hierarchicalLoggingEnabled was true.  This makes no sense to me since
detached Loggers aren't part of a Logger hierarchy.

Fixes https://github.com/dart-lang/logging/issues/34.
mosuem referenced this issue Oct 16, 2024
…art-archive/logging#71)

Previously detached Loggers could log messages only if
hierarchicalLoggingEnabled was true.  This makes no sense to me since
detached Loggers aren't part of a Logger hierarchy.

Fixes https://github.com/dart-lang/logging/issues/34.
@mosuem mosuem transferred this issue from dart-archive/logging Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants