Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

[wip] log manager POC #52

Closed
wants to merge 3 commits into from
Closed

[wip] log manager POC #52

wants to merge 3 commits into from

Conversation

pq
Copy link
Contributor

@pq pq commented Oct 31, 2018

Log Manager POC (see dart-lang/core#441).

Not for landing.

/cc @jacob314 @devoncarew @kevmoo @natebosch

lib/logging.dart Outdated

/// A shared manager instance whose recorded messages are logged to the
/// developer console.
final LogManager logManager = LogManager()..onRecord.listen((record) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe name this class by what it does.
DeveloperConsoleLogger, FilteredDeveloperConsoleLogger, etc?

}

/// Returns a stream of messages added to loggers enabled by this manager.
Stream<LogRecord> get onRecord => _logController.stream;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this exposed for testing or for users? If you are implementing the full Logger api, might make sense to implement Logger.

Stream<LogRecord> get onRecord => _logController.stream;

/// Enable (or disable) logging of messages sent to the given [logger].
void enableLogging(String logger, {bool enable = true}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calling this variable logger here and elsewhere is a little counterintuitive to me as there is also a Logger class that means something different. Is there a good name for these logging channel names? Perhaps channelName if there isn't something snappier.


// Fire events for new loggers.
_loggerAddedBroadcaster.stream.listen((String name) {
developer.postEvent('logging.logger.added', <String, dynamic>{
Copy link
Contributor

@jacob314 jacob314 Nov 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging.logger seems a little redundant.
maybe
ext.logging.added
or something similar?

}) {
assert(name != null);
assert(callback != null);
final methodName = 'ext.dart.logging.$name';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just
ext.logging.name as all service extensions within a dart program are dart service extensions.


/// Registers a service extension method with the given name and a callback to
/// be called when the extension method is called.
void _registerServiceExtension({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably make this method public but protected so you can override it for testing.


/// Whether messages to the given [logger] should be logged by this manager.
/// @see [enableLogging]
bool shouldLog(String logger) => _enabledLoggers.contains(logger);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:
maybe
isLogged?

Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Sorry about all the comments. For some reason, logging framework code is a honeypot for bike shedding.

@pq
Copy link
Contributor Author

pq commented Nov 1, 2018

@natebosch : this POC shows how our use cases could be addressed by adding on to current package:logging facilities. We'd be able to do things a little differently if we did reboot logging but this should give you a bit more insight into our motivations.

@jacob314 jacob314 requested a review from kevmoo November 1, 2018 16:50
@jacob314
Copy link
Contributor

jacob314 commented Nov 1, 2018

@kevmoo who has a lot of experience with this package.

@kevmoo
Copy link
Contributor

kevmoo commented Nov 1, 2018 via email

@pq
Copy link
Contributor Author

pq commented Dec 4, 2018

Tabling for now. Thanks for all the productive conversation!

@pq pq closed this Dec 4, 2018
@kevmoo kevmoo deleted the log_manager branch August 2, 2019 18:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants