Skip to content

Commit

Permalink
Refactor logging code
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn committed May 29, 2017
1 parent 69f7a7b commit 2f70d56
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion bin/medic-conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node

const usage = require('../src/cli/utils').usage;
const log = require('../src/cli/utils').log;

if(process.argv.length < 4) {
usage();
Expand Down
3 changes: 2 additions & 1 deletion src/cli/all.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const big_log = require('./utils').big_log;
const big_log = (...args) => { require('../lib/log')('!!', ...args); };

const compileAppSettings = require('../fn/compile-app-settings');
const backupAppSettings = require('../fn/backup-app-settings');
const uploadAppSettings = require('../fn/upload-app-settings');
Expand Down
9 changes: 0 additions & 9 deletions src/cli/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,3 @@ Usage:
$0 <projectName> <instanceUrl>
`);
};

module.exports.log = (...args) => logAtLevel('INFO', ...args);
module.exports.warn = (...args) => logAtLevel('WARN', ...args);
module.exports.big_log = (...args) => module.exports.log('!!', ...args);

function logAtLevel(level, ...args) {
args.unshift(level);
console.log.apply(console.log, args);
}
2 changes: 1 addition & 1 deletion src/fn/upload-forms.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('../lib/sync-fs');
const attachmentsFromDir = require('../lib/attachments-from-dir');
const warn = require('../cli/utils').warn;
const warn = require('../lib/log').warn;

const PouchDB = require('pouchdb');

Expand Down
8 changes: 8 additions & 0 deletions src/lib/log.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = (...args) => logAtLevel('INFO', ...args);
module.exports.info = module.exports;
module.exports.warn = (...args) => logAtLevel('WARN', ...args);

function logAtLevel(level, ...args) {
args.unshift(level);
console.log.apply(console.log, args);
}

0 comments on commit 2f70d56

Please sign in to comment.