Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
fix(scripts): nicely stringify regexps when logging config
Browse files Browse the repository at this point in the history
  • Loading branch information
philbooth committed Oct 6, 2016
1 parent f7d1dc3 commit 479b034
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions bin/key_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ function main() {
log.info({ op: 'geodb.check', result: result })
})

process.stdout.write(JSON.stringify({
event: 'config',
data: config
}) + '\n')
// RegExp instances serialise to empty objects, display regex strings instead.
const stringifiedConfig =
JSON.stringify(config, (k, v) =>
v && v.constructor === RegExp ? v.toString() : v
)

process.stdout.write('{"event":"config","data":' + stringifiedConfig + '}\n')

if (config.env !== 'prod') {
log.info(config, 'starting config')
log.info(stringifiedConfig, 'starting config')
}

var error = require('../lib/error')
Expand Down

0 comments on commit 479b034

Please sign in to comment.