Remove values for a few keys from exported log for privacy. Fix #1147.

This commit is contained in:
FelisCatus 2017-08-05 22:28:11 -04:00
parent 7bc8655421
commit 32cb2f909e

View File

@ -1,6 +1,14 @@
### @module omega-target/log ###
Log = require './log'
replacer = (key, value) =>
switch key
# Hide values for a few keys with privacy concerns.
when "username", "password", "host", "port"
return "<secret>"
else
value
# Log is used as singleton.
# coffeelint: disable=missing_fat_arrows
module.exports = Log =
@ -20,7 +28,7 @@ module.exports = Log =
else if obj instanceof Error
obj.stack || obj.message
else
JSON.stringify(obj, null, 4)
JSON.stringify(obj, replacer, 4)
else if typeof obj == 'function'
if obj.name
"<f: #{obj.name}>"