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

improve LogError #3843

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

toaster
Copy link
Member

@toaster toaster commented Apr 21, 2023

Description:

This PR adds another line of context to LogError output. This is at least useful for all messages generated by Fyne itself because it does not help to know the location of the logging in Fyne but one needs to know the location of the caller of the logging Fyne method (maybe even further but that has to be proven).

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

For the usages inside Fyne, the actual caller line is not really helpful.
Instead, the caller of the caller is interesting most of the time.

For usages outside Fyne, it might be different.

Therefore, we now log both.
@toaster toaster requested a review from andydotxyz April 21, 2023 17:21
@toaster
Copy link
Member Author

toaster commented Apr 21, 2023

Mea culpa … didn’t know that we actually have a test for the error logger :).

@coveralls
Copy link

Coverage Status

Coverage: 62.135% (+0.004%) from 62.131% when pulling b701812 on toaster:refactoring/improve_fyne_log_error into c0b6014 on fyne-io:develop.

@toaster toaster marked this pull request as ready for review April 21, 2023 18:25
@Jacalz
Copy link
Member

Jacalz commented Apr 22, 2023

I wonder if there perhaps is a better way to generate a stack trace (instead of using runtime.Callers() in a loop)? I did some research and found runtime.Stack(), debug.Stack() and debug.PrintStack().

@andydotxyz
Copy link
Member

What this originally aimed to do was print the most likely like that caused a problem.
With the improvements it gets more helpful, but we should not put in a full stack in my opinion as it would get too long.
I'm not sure if the byte[] output of the suggested methods is really something we can work with?

@Jacalz
Copy link
Member

Jacalz commented Apr 28, 2023

I suppose you’re right. I’m not entirely sure about this change. Like you say, the initial implementation is nice because it prints the most likely error location. I was quite happy with the current behaviour of the logging.

What this PR is trying to do seems to me like what you usually would use a debugger for. Or am I perhaps too old school in saying that (I’ve done way too much C++ recently)?

@Bluebugs
Copy link
Contributor

I think log are for user report error and debugger are for developers. In this case, having a full stack report can sometime be useful, but not always. I would propose to either have the stack display when doing not doing a release build or when an environment variable is set.

@Jacalz
Copy link
Member

Jacalz commented Apr 28, 2023

That sounds like a good plan. I'm definitely in favour of release builds (using that build tag) keeping the logging as is and debug builds providing more information.

@andydotxyz
Copy link
Member

We also have a handy "debug" tag that is perhaps where a full stack report would live?

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 this pull request may close these issues.

None yet

5 participants