Skip to content

Commit

Permalink
Always translate the log level.
Browse files Browse the repository at this point in the history
Fixes the error "Invalid log level.  Using the default instead." produced when specifying the 'verbose' or 'http' log levels. Also add the 'debug' level mapping.
  • Loading branch information
mariocasciaro authored and darinspivey committed Dec 17, 2020
1 parent 72c612d commit 7be3610
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const levelTranslate = new Map([
, ['info', 'info']
, ['http', 'debug']
, ['verbose', 'debug']
, ['debug', 'debug']
, ['silly', 'trace']
])
/*
Expand All @@ -28,19 +29,21 @@ module.exports = class LogDNATransport extends Transport {
}

log(info, callback) {
const level = levelTranslate.get(info.level)

if (info.error instanceof Error) {
info.error = info.error.stack || info.error.toString()
}

if (!info.message) {
// Send the incoming object payload as the message
const level = levelTranslate.get(info.level)
this.logger.log(info, level)
callback(null, true)
return
}

const {level, message, indexMeta, timestamp, ...meta} = info
// eslint-disable-next-line no-unused-vars
const {level: _, message, indexMeta, timestamp, ...meta} = info
const opts = {
level
, indexMeta
Expand Down

0 comments on commit 7be3610

Please sign in to comment.