Skip to content

Commit

Permalink
feat(loglevel): set the loglevel via env variables (#70)
Browse files Browse the repository at this point in the history
* feat(loglevel): set the loglevel via env variables

* docs(loglevel): set loglevel via env variable

Co-authored-by: Dean Gite <[email protected]>
Co-authored-by: l.mauser <[email protected]>
  • Loading branch information
3 people authored Oct 6, 2022
1 parent c348081 commit fc80394
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export default {
| fsTppVersion | undefined | _DEPRECATED: use [`FSXA_SNAP_URL`](https://github.com/e-Spirit/fsxa-pattern-library/#snap-url) instead_ You can provide a version for tpp-snap. Check [this](https://www.npmjs.com/package/fs-tpp-api) out for more details. |
| enableEventStream | false | When enabled, events for `insert`, `replace` and `delete` CaaS documents can be observed and handled. It's currently used in preview mode, to sync updated data in FirstSpirit with the CaaS and the App State. |

The LogLevel can also be set by providing an env variable called `FSXA_LOG_LEVEL`. This will be priorized over the configuration file option.

## Legal Notices

FSXA-Nuxt-Module is a product of [Crownpeak Technology GmbH](http://www.e-spirit.com), Dortmund, Germany.
Expand Down
7 changes: 7 additions & 0 deletions src/module/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export interface FSXAModuleOptions {
client?: string;
};
}

const LOG_LEVEL: string = process.env.FSXA_LOG_LEVEL;

const FSXAModule: Module<FSXAModuleOptions> = function (moduleOptions) {
// try to access config file
let fileConfiguration = {};
Expand All @@ -46,6 +49,10 @@ const FSXAModule: Module<FSXAModuleOptions> = function (moduleOptions) {
if (configFilePath) {
// eslint-disable-next-line
fileConfiguration = require(configFilePath).default;
// ENV variable will take the priority
if (LOG_LEVEL && LOG_LEVEL in LogLevel) {
fileConfiguration["logLevel"] = LOG_LEVEL;
}
// watch config file
if (this.nuxt.options.dev) {
this.nuxt.options.watch.push(configFilePath);
Expand Down

0 comments on commit fc80394

Please sign in to comment.