Skip to content

Commit

Permalink
feat: added feature to set log level in env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
JanssenBrm committed May 24, 2024
1 parent 5d3ea9b commit a944a6b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ import { v4 as uuidv4 } from 'uuid';
imports: [ConfigModule],
inject: [ConfigService],
useFactory: async (config: ConfigService) => {
const level = config.get('general.debug') ? 'debug' : 'info';
return {
level,
level: config.get('general.loglevel'),
pinoHttp: {
level,
level: config.get('general.loglevel'),
genReqId: (request) =>
request.headers['x-correlation-id'] || uuidv4(),
transport: config.get('general.pretty')
Expand Down
12 changes: 6 additions & 6 deletions src/config/schema/config.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export const schema: convict.Schema<AppConfig> = {
env: 'PORT',
arg: 'port',
},
debug: {
doc: 'Enable debug logging',
format: 'Boolean',
default: false,
env: 'DEBUG',
arg: 'debug',
loglevel: {
doc: 'Set the log level',
format: 'String',
default: 'error',
env: 'LOG_LEVEL',
arg: 'loglevel',
},
pretty: {
doc: 'Enable pretty logging',
Expand Down

0 comments on commit a944a6b

Please sign in to comment.