| id | logging |
|---|---|
| title | Logging |
| sidebar_label | Logging Convention |
- Inbuilt
loggingmodule is used in most cases. You can look into structlog for more granular logging. loggingis always a must. Use the following levels as required:- DEBUG: log parameters and arguments. Information needed when we need to debug or develop. Should be avoided in production.
- INFO: log basic information such as function entry, file being processed et al
- WARN: log user security and other warnings that may require attention or may need to be avoided.
- ERROR: errors in programs.
- CRITICAL: blocking issues or immediate attention issues.
loggeris used for naming single logger object. UseNAME_loggername for more than one logger when required.- It is singleton and single threaded by default for given name of the logger. Can be non-blocking if required.
- See Logging Cookbook for reference.
- ERROR and CRITICAL levels should be mitigated and informed.
- Always use
exceptionmethod rather thanerrormethod ofloggerobject to log traceback when catching exceptions.
- Always use
- Learn more about Exception Handling and Logging in detail here