Skip to content

Commit 4555503

Browse files
authored
Merge pull request Sofie-Automation#1147 from nrkno/doc/log-levels
Doc: Log Levels
2 parents 842c6e3 + 6cc4004 commit 4555503

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/documentation/docs/for-developers/contribution-guidelines.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,21 @@ Also, each of the libraries has a minimum nodejs version specified in their pack
7676
We sometimes use the `yarn resolutions` property in `package.json` to fix security vulnerabilities in dependencies of libraries that haven't released a fix yet. If adding a new one, try to make it as specific as possible to ensure it doesn't have unintended side effects.
7777

7878
When updating other dependencies, it is a good idea to make sure that the resolutions defined still apply and are correct.
79+
80+
### Logging
81+
82+
When logging, we try to adher to the following guideliness:
83+
84+
Usage of `console.log` and `console.error` directly is discouraged (except for quick debugging locally). Instead, use one of the logger libraries (to output json logs which are easier to index).
85+
When logging, use one of the **log level** described below:
86+
87+
| Level | Description | Examples |
88+
| ------- | ----------- | -- |
89+
| `silly` | For very detailed logs (rarely used). | - |
90+
| `debug` | Logging of info that could be useful for developers when debugging certain issues in production. | `"payload: {>JSON<} "`<br></br>`"Reloading data X from DB"` |
91+
| `verbose` | Logging of common events. | `"File X updated"` |
92+
| `info` | Logging of significant / uncommon events.<br></br>_Note: If an event happens often or many times, use `verbose` instead._ | `"Initializing TSR..."`<br></br>`"Starting nightly cronjob..."`<br></br>`"Snapshot X restored"`<br></br>`"Not allowing removal of current playing segment 'xyz', making segment unsynced instead"`<br></br>`"PeripheralDevice X connected"` |
93+
| `warn` | Used when something unexpected happened, but not necessarily due to an application bug.<br></br>These logs don't have to be acted upon directly, but could be useful to provide context to a dev/sysadmin while troubleshooting an issue. | `"PeripheralDevice X disconnected"`<br></br>`"User Error: Cannot activate Rundown (Rundown not found)" `<br></br>`"mosRoItemDelete NOT SUPPORTED"` |
94+
| `error` | Used when something went _wrong_, preventing something from functioning.<br></br>A logged `error` should always result in a sysadmin / developer looking into the issue.<br></br>_Note: Don't use `error` for things that are out of the app's control, such as user error._ | `"Cannot read property 'length' of undefined"`<br></br>`"Failed to save Part 'X' to DB"`|
95+
| `crit` | Fatal errors (rarely used) | - |
96+

0 commit comments

Comments
 (0)