Skip to content
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

Provide a default print-logger #61

Open
LinusU opened this issue May 20, 2019 · 4 comments
Open

Provide a default print-logger #61

LinusU opened this issue May 20, 2019 · 4 comments
Labels
type-enhancement A request for a change that isn't a bug

Comments

@LinusU
Copy link

LinusU commented May 20, 2019

I think it could be very useful to provide a print-logger function that can be registered as a listener to the log stream. The current one-liner that's in the example doesn't log the .error and .stackTrace variables, so many people that just pastes it in will probably not get that information in their logs.

I'm thinking something like this:

Logger.root.level = Level.ALL;
Logger.root.onRecord.listen(PrintLogger());

or maybe even:

Logger.setup(Level.ALL, PrintLogger())

Would be happy to submit pull requests if we know what we want :)

@natebosch
Copy link
Member

See also #12

I do think there is some room for shipping utilities like this, probably under a separate import. The blocker here is that it's not clear to me we could provide something that satisfies enough users to make it worthwhile - the log listeners and formatters that I've come across generally have some subtle or major differences that are hard to rectify...

@natebosch natebosch added the type-enhancement A request for a change that isn't a bug label Mar 12, 2020
@allentv
Copy link

allentv commented May 10, 2020

I would prefer to have the default logger push out just the error message to stdout when I call log.error with the caller information, rather than the whole trace. This keeps it simple to manage and points towards areas of further investigation. If colors are available, that would make it easier to spot for terminals where colors are available.

@natebosch
Copy link
Member

Most use cases I'm aware of would probably prefer stderr over stdout, and they don't have a consistent preference for determining color support, or overriding that detection.

Most likely what we'd need in order to accept a standard logger or formatter into this package is buy in from a sufficient number of stakeholders with agreement on a behavior and format. That means coordinating with existing first party tools using this library (tools in the SDK, build_runner/webdev, stuff in flutter). It's not likely to be an effort that is easy to drive from the community.

A better approach might be to ship something in a separate package, and drive consensus from the bottom up.

@hpoul
Copy link

hpoul commented Aug 18, 2020

fwiw, I've published a simple logging appender package a while ago which is basically PrintAppender.setupLogging(); to have a decent default setup (and some simple coloring when attached to a terminal). Although right now everything goes to stdout, but i would be happy to experiment with stderr/stdout options if anyone has some suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants