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

Enhance logging and add logs for Service methods #246

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions backend/guides/logging/logging_rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Rules for Logging

## 1. Logging a variable:

- Import logger to whichever file you need logging for, and do `logger.log(level, msg, obj)` on a variable/const whose value you want to keep track of. If you can think of a better way of doing this, other than just putting it in a pass-through function, please let me know so
we can consider that option instead.
- Include in your log the variable's name, the method/function it belongs to and the value of the variable (if applicable).

## 2. Other rules:

- We only need **error, warn, info, debug** for logging, so please stick to these and do not add more log levels to our logger.
- Similarly, please do not push any changes to the base format of the logs determined at the createLogger() call. Please go over any
changes you would like to make with the team beforehand regarding the base format.
- Feel free to add even more information to your logs than what is required. However, you must have all that is mentioned above in rules 1 to 4 at the minimum.
- If logging manually using `logger` itself, please only use **logger.log()** and not _logger.{error, warn, info, debug}()_ for consistency.
18 changes: 18 additions & 0 deletions backend/guides/logging/usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Log Usage

## Error logging:

- Should only be used when an error occurs, i.e. an object is **null** when it's not supposed to. In general, use this when something that isn't supposed to happen happens, or when something goes wrong.

## Warn logging:

- Should be used when a problem occurs that is serious enough to let (oncall) developers know just in case, but not serious enough to be called an _error_, i.e. it does not affect the operations of the backend API.

## Info logging:

- This should be used to display various information about the current state of the backend code when it is processing certain requests and responses, among other things, particularly information that would be useful for production/oncall debugging.
- Try not to use this for error and warning logs.

## Debug logging

- This should be used to display various information about the current state of the backend code particularly information that would be useful for developers for (local) development and debugging.
Loading