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

Not using provided FormatEvent #13

Open
cecton opened this issue Nov 5, 2020 · 2 comments
Open

Not using provided FormatEvent #13

cecton opened this issue Nov 5, 2020 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed Seeking feedback

Comments

@cecton
Copy link

cecton commented Nov 5, 2020

I have an issue with your library because the logs are reported using a Layer which bypasses the FormatEvent of tracing_subscriber.

In my use case I have made my own FormatEvent which I use in place of the default one provided by tracing-subscriber. This allows me to customize the log lines.

🤔 I don't know if I have a solution for this... FormatEvent is using a Writer to write the log lines (which is provided by the user). Maybe it would be possible to spawn a task that would read the log lines from a Reader and call the log() function from there but logging in the browser console is kinda complicated because there are log arguments to change the colors and stuff... I would probably need to serialize things.

@colelawrence
Copy link
Member

Interesting! I had not seen this capability, before, but it looks pretty neat.

The main issue that we need to consider is how do we allow or disallow usage of color styling, which is something that I feel improves the legibility of the logs (using console.log("%cWARN", "color: orange", "Warning message"))?
https://developer.mozilla.org/en-US/docs/Web/API/console#usage

I suppose for the time being we could enable toggling the prefix & additionally use the FormatEvent (behind a fmt feature) for the rest of the message's printing.

WDYT?

@cecton
Copy link
Author

cecton commented Mar 3, 2021

It's been a long time. 😁

hmm what you say sounds right? I think. If I understand right you would allow logging with the FormatEvent in a crate feature. Otherwise it would use the current behavior that you have. I guess that's the best we can do.

Meanwhile I think I implemented something custom. I probably won't get back to it before a long time so don't feel to urge to implement anything. Maybe my use case is kinda rare and not necessarily worth the effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed Seeking feedback
Projects
None yet
Development

No branches or pull requests

2 participants