mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-07 05:52:57 +00:00
feat: add logger
This commit is contained in:
43
README.md
Normal file
43
README.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# @openstapps/logger
|
||||
|
||||
[](https://gitlab.com/openstapps/logger/commits/master)
|
||||
[](https://gitlab.com/openstapps/logger/commits/master)
|
||||
|
||||
This is a simple logger for TypeScript projects with colors for console output.
|
||||
|
||||
Logs are only printed if their log level is equal or higher than the defined log level.
|
||||
|
||||
## Log Levels
|
||||
Available Log levels are:
|
||||
- 1 - INFO
|
||||
- 2 - LOG
|
||||
- 4 - WARN
|
||||
- 8 - ERROR
|
||||
- 16 - OK
|
||||
|
||||
You can set your Log Level with the environment variable
|
||||
`STAPPS_LOG_LEVEL` in a binary way.
|
||||
|
||||
For example `STAPPS_LOG_LEVEL=17` is 16 + 1 and would log everything
|
||||
that is `OK` or `ERROR`.
|
||||
|
||||
If you want to use Logger in production (`NODE_ENV=production`) and allow all transports to fail set `ALLOW_NO_TRANSPORT` to `true`.
|
||||
|
||||
## SMTP
|
||||
This class also provides a simple implementation of an smtp transport which can be used as a
|
||||
`TransportWithVerification` for the logger. You can use this to transport errors of the logger or to transport mails
|
||||
of your own monitoring solution.
|
||||
|
||||
### Usage
|
||||
You can instatiate it with a config or it will check for a config in the environment variables.
|
||||
|
||||
Environment variables are:
|
||||
* SMTP_AUTH_USER: SMTP username
|
||||
* SMTP_AUTH_PASSWORD: SMTP password
|
||||
* SMTP_HOST: SMTP host
|
||||
* SMTP_PORT: SMTP port
|
||||
* SMTP_RECIPIENTS: comma seperated list of recipients
|
||||
* SMTP_CC: comma seperated list of recipients for the carbon copy (CC)
|
||||
* SMTP_SENDER_MAIL: sender of the mail
|
||||
* SMTP_SENDER_NAME: name of the sender
|
||||
* SMTP_SECURE: `true` to enable tls
|
||||
Reference in New Issue
Block a user