diff --git a/lib/actions/app.coffee b/lib/actions/app.coffee index 3c3ef6bc..80e0b25b 100644 --- a/lib/actions/app.coffee +++ b/lib/actions/app.coffee @@ -2,6 +2,7 @@ _ = require('lodash') async = require('async') device = require('../device/device') table = require('../table/table') +log = require('../log/log') server = require('../server/server') widgets = require('../widgets/widgets') applicationModel = require('../models/application') @@ -11,7 +12,7 @@ config = require('../config') exports.list = authHooks.failIfNotLoggedIn -> applicationModel.getAll().then (applications) -> - console.log table.horizontal applications, (application) -> + log.out table.horizontal applications, (application) -> application.device_type = device.getDisplayName(application.device_type) application['Online Devices'] = _.where(application.device, is_online: 1).length application['All Devices'] = application.device?.length or 0 @@ -26,7 +27,7 @@ exports.list = authHooks.failIfNotLoggedIn -> exports.info = authHooks.failIfNotLoggedIn (id) -> applicationModel.get(id).then (application) -> - console.log table.vertical application, (application) -> + log.out table.vertical application, (application) -> application.device_type = device.getDisplayName(application.device_type) delete application.device return application diff --git a/lib/actions/device.coffee b/lib/actions/device.coffee index 3116ab83..d3fba431 100644 --- a/lib/actions/device.coffee +++ b/lib/actions/device.coffee @@ -1,13 +1,14 @@ _ = require('lodash') deviceModel = require('../models/device') getDeviceDisplayName = require('../device/device').getDisplayName +log = require('../log/log') table = require('../table/table') authHooks = require('../hooks/auth') exports.list = authHooks.failIfNotLoggedIn (applicationId) -> deviceModel.getAll(applicationId).then (devices) -> - console.log table.horizontal devices, (device) -> + log.out table.horizontal devices, (device) -> device.application = device.application[0].app_name device.device_type = getDeviceDisplayName(device.device_type) delete device.note diff --git a/lib/actions/keys.coffee b/lib/actions/keys.coffee index 22a8db29..31090d4a 100644 --- a/lib/actions/keys.coffee +++ b/lib/actions/keys.coffee @@ -1,6 +1,7 @@ _ = require('lodash') server = require('../server/server') authHooks = require('../hooks/auth') +log = require('../log/log') table = require('../table/table') helpers = require('../helpers/helpers') keyModel = require('../models/key') @@ -9,7 +10,7 @@ config = require('../config') exports.list = authHooks.failIfNotLoggedIn -> server.get config.urls.keys, (error, response, keys) -> throw error if error? - console.log table.horizontal keys, (key) -> + log.out table.horizontal keys, (key) -> delete key.public_key return key , [ 'ID', 'Title' ] @@ -27,4 +28,4 @@ exports.info = authHooks.failIfNotLoggedIn (id) -> throw new Error("Key #{id} doesn't exists") key.public_key = '\n' + helpers.formatLongString(key.public_key, config.sshKeyWidth) - console.log(table.vertical(key, _.identity, [ 'ID', 'Title', 'Public Key' ])) + log.out(table.vertical(key, _.identity, [ 'ID', 'Title', 'Public Key' ])) diff --git a/lib/app.coffee b/lib/app.coffee index 50c1d6e7..2f074e3c 100644 --- a/lib/app.coffee +++ b/lib/app.coffee @@ -1,4 +1,5 @@ data = require('./data/data') +log = require('./log/log') config = require('./config') packageJSON = require('../package.json') @@ -70,7 +71,7 @@ program .command('version') .description('Show version') .action -> - console.log(packageJSON.version) + log.out(packageJSON.version) # ---------- Keys Module ---------- keys = require('./actions/keys')