-
-
Notifications
You must be signed in to change notification settings - Fork 244
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
169 improve logging #499
base: master
Are you sure you want to change the base?
169 improve logging #499
Conversation
- Handles the log functions. - Handles listening and outputting logs to the console.
definitely yes 😍! There is indeed a lack of logging everywhere in the application. Is logger.abs.dart generated from someting or does it come from some example in the logging package? |
Logger.abs.dart is based on the log levels you can find here https://github.com/dart-lang/logging/tree/master/lib/src and the functions used to log at each level. It's nice to have since by setting up the logger with late final Logging logger = LoggingAdaptor('HomeTabsScreen'); in classes, if you ever want to replace the logger, you can make a new adaptor and switch it in one location and have all the logger calls still passed to it. E.g. updating to Would just replace the function that logger.fine() calls. |
i don't think i've ever found levelled logging useful. in my experience, you spend work up front categorizing logs into categories, but when there's an issue and you actually need to debug, you want to see detail of some components, but not others (e.g. http request+response of a specific api call, but not all the other ones). switching to "fine" or "debug" or whatever just to see what you need, would also result in way more output of a gazillion things you don't care about. so in practice i've always ended up using tools like network inspectors, debuggers, or adding some prints to the code to troubleshoot a specific issue.
maybe i'm missing something here, but it seems trivial to me to glance at this function and see that everything is wrapped in try/catch blocks. i agree that to check correctness of individual calls, you'd need to go into each one, check that it handles http responses properly, etc; but i don't see how this is any different from the case where you want to check that each call logs correctly. you'd also need to go into each one and do the same. The bigger problem i see is that we don't communicate about error conditions to the user. i'm pretty sure i've run into it where things would fail, and the app would just hang |
Description
Looking into _loadEntries() there are a lot of initialisation calls being triggered and manually tracking each one to see if they are wrapped correctly in try/catches or if the response body is valid then testing if it is logged would be very time consuming.
'info' -> page navigation logs.
'fine' -> api calls
'finer' -> api calls and responses
etc...
Benefits:
e.g. If you want to add firebase crashlytics later, on initialisation of crashlytics you can call a function much like the logging adaptor does and pipe all the error logs to it.
static void listenForLogs() {
Link to the issue :
#169
Example log outputs
Checklist
Please check that the PR fulfills all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).