Skip to content

Commit

Permalink
Fix logging of JSON objects
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn committed Jun 30, 2017
1 parent dfea568 commit 45bfd1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medic-configurer-beta",
"version": "1.0.53",
"version": "1.0.54",
"description": "Configure Medic Mobile deployments",
"main": "index.js",
"scripts": {
Expand Down
5 changes: 4 additions & 1 deletion src/lib/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ function logAtLevel(level, ...args) {
console.log.apply(console.log, args.map(redactUrls));
}

const redactUrls = s => s && s.toString().replace(/(http[s]?:\/\/[^:]*):[^@]*@/g, '$1:****@');
const redactUrls = s => {
if(s && typeof s !== 'string') s = JSON.stringify(s);
return s && s.replace(/(http[s]?:\/\/[^:]*):[^@]*@/g, '$1:****@');
};

0 comments on commit 45bfd1a

Please sign in to comment.