feat: allow env variables to overwrite smtp config

Fixes #3
This commit is contained in:
Anselm Stordeur
2019-01-09 17:53:53 +01:00
parent cdbbb0ae1f
commit 3d82c94577
4 changed files with 199 additions and 84 deletions

View File

@@ -8,28 +8,30 @@ 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:
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.
You can set your log level with the environment variable `STAPPS_LOG_LEVEL`.
For example `STAPPS_LOG_LEVEL=17` is 16 + 1 and would log everything
that is `OK` or `ERROR`.
To select your desired log levels add the corresponding numbers and set the value of `STAPPS_LOG_LEVEL` to the sum.
If you want to use Logger in production (`NODE_ENV=production`) and allow all transports to fail set `ALLOW_NO_TRANSPORT` to `true`.
For example `STAPPS_LOG_LEVEL=17` is 16 + 1 and would log everything that is `OK` or `INFO`.
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
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.
You can instatiate it with a config or it will check for a config in the environment variables. Environment variables
can overwrite the actual config values.
Environment variables are:
* SMTP_AUTH_USER: SMTP username