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

The level of logging for Trace should not be locked to Info. #93

Open
J0eJ0h opened this issue Sep 6, 2020 · 2 comments · May be fixed by #101
Open

The level of logging for Trace should not be locked to Info. #93

J0eJ0h opened this issue Sep 6, 2020 · 2 comments · May be fixed by #101

Comments

@J0eJ0h
Copy link

J0eJ0h commented Sep 6, 2020

It should be possible to explicitly set the level on Trace. (Imagine Info is turned off and a failure mode where you really want to know the time it took to recover).

I initially thought I could do it with the Level field in Entry, but it's never honored.

The reason this is an issue, not a PR, is that this is a great library and I defer to the core team on how to handle this.
That said, for this issue I'd just add a new TraceAt that took the level in, and modify the base Trace and Stop to use the Level field in Entry.

@tj
Copy link
Member

tj commented Sep 7, 2020

Hmm if you have an error the trace should be using the error severity: https://github.com/apex/log/blob/master/entry.go#L156, but yeah as you mentioned there's no way to tweak the initial Trace event, I'm not sure what would be best there.

I always enable INFO level in production personally, it's better to have more info than not enough, which is partly why I started https://apex.sh/logs/ :D, it's cost-effective enough to hold onto all those INFOs. I'm not against adding something like TraceAt() but wouldn't the Stop(err) be enough in the case you're mentioning?

@ProExpertProg
Copy link

This would be a very desired feature; There are a lot of times when we want to use a Trace with DebugLevel. Current best option is to manually implement that.

If I make a PR, would there be interest in merging it?

sjbarag added a commit to sjbarag/log that referenced this issue Apr 16, 2022
The Trace() and Stop() methods for an Entry default to Info-level
logging, and previously didn't offer a way to log non-errors at any
other level. Add a WithTraceAt() method to allow that level to be
configured.

fixes apex#93
@sjbarag sjbarag linked a pull request Apr 16, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants