Fix logger clutter message (#201)

* Fix logger message handling

* Fix standard styling issues
This commit is contained in:
Rafael Taranto 2018-10-31 12:25:59 -03:00 committed by Josh Harvey
parent de8a380bd8
commit 65ce8aee3d
2 changed files with 7 additions and 10 deletions

View file

@ -16,21 +16,19 @@ const MAX_CONTENT_LENGTH = 2000
// How long a machine can be down before it's considered offline // How long a machine can be down before it's considered offline
const STALE_INTERVAL = '2 minutes' const STALE_INTERVAL = '2 minutes'
module.exports = {update, mapRecord} module.exports = { update, mapRecord }
function mapCoin (info, deviceId, cryptoCode) { function mapCoin (info, deviceId, cryptoCode) {
const config = info.config const config = info.config
const rates = info.rates[cryptoCode] || {cashIn: null, cashOut: null} const rates = info.rates[cryptoCode] || { cashIn: null, cashOut: null }
const cryptoConfig = configManager.scoped(cryptoCode, deviceId, config) const cryptoConfig = configManager.scoped(cryptoCode, deviceId, config)
const unscoped = configManager.unscoped(config) const unscoped = configManager.unscoped(config)
const showRates = unscoped.coinAtmRadarShowRates const showRates = unscoped.coinAtmRadarShowRates
const cashInFee = showRates ? cryptoConfig.cashInCommission / 100 : null const cashInFee = showRates ? cryptoConfig.cashInCommission / 100 : null
const cashOutFee = showRates ? cryptoConfig.cashOutCommission / 100 : null const cashOutFee = showRates ? cryptoConfig.cashOutCommission / 100 : null
const cashInRate = showRates ? _.invoke('cashIn.toNumber', rates) : null const cashInRate = showRates ? _.invoke('cashIn.toNumber', rates) : null
const cashOutRate = showRates ? _.invoke('cashOut.toNumber', rates) : null const cashOutRate = showRates ? _.invoke('cashOut.toNumber', rates) : null
return { return {
cryptoCode, cryptoCode,
@ -151,9 +149,9 @@ function update (info) {
return mapRecord(info) return mapRecord(info)
.then(sendRadar) .then(sendRadar)
.catch(err => logger.error(err)) .catch(err => logger.error(`Failure to update CoinATMRadar`, err))
} }
function computeOperatorId (masterSeed) { function computeOperatorId (masterSeed) {
return hkdf(masterSeed, 32, {salt: 'lamassu-server-salt', info: 'operator-id'}).toString('hex') return hkdf(masterSeed, 32, { salt: 'lamassu-server-salt', info: 'operator-id' }).toString('hex')
} }

View file

@ -1,6 +1,6 @@
const winston = require('winston') const winston = require('winston')
const options = require('./options') const options = require('./options')
const _ = require('lodash') const _ = require('lodash/fp')
const logger = new winston.Logger({ const logger = new winston.Logger({
level: options.logLevel, level: options.logLevel,
@ -8,8 +8,7 @@ const logger = new winston.Logger({
new (winston.transports.Console)({ timestamp: true, colorize: true }) new (winston.transports.Console)({ timestamp: true, colorize: true })
], ],
rewriters: [ rewriters: [
(...[,, meta]) => _.hasIn('toString', meta) (...[,, meta]) => meta instanceof Error ? { message: meta.message, stack: meta.stack } : meta
? meta.toString() : 'Error, no further information is available'
] ]
}) })