winston added as our logger by default

This commit is contained in:
Jordi Montes 2018-01-22 12:24:19 +01:00
parent 0a2eb7972d
commit f2bb705960
3 changed files with 62 additions and 52 deletions

View File

@ -1,16 +1,25 @@
const winston = require('winston');
const SignerProvider = require('ethjs-provider-signer');
const sign = require('ethjs-signer').sign;
const Eth = require('ethjs-query');
const prices = require('./prices');
const config = require('../config');
const provider = new SignerProvider(config.signerPath, {
signTransaction: (rawTx, cb) => cb(null, sign(rawTx, process.env.KEY)),
accounts: (cb) => cb(null, [address]),
});
const eth = new Eth(provider);
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
transports: [
new winston.transports.File({ filename: 'error.log', level: 'error' }),
new winston.transports.File({ filename: 'info.log', level: 'info'}),
new winston.transports.File({ filename: 'combined.log' })
]
});
const bountyLabels = {
'bounty-xs': 1,
@ -69,8 +78,8 @@ const getGasPrice = function(req) {
// Check how to handle errors when promises does not arrive
}
const log = function() {
console.log(arguments);
const log = function(msg) {
logger.info(msg);
}
module.exports = {

View File

@ -1,12 +1,12 @@
/*
* Bot that receives a POST request (from a GitHub issue comment webhook)
* and in case it's a comment that has "@autobounty <decimal> <currency>"
* awards that bounty to the address posted earlier in the thread (by the
* commiteth bot).
* TODO tests
* REVIEW parsing, non-persisting storage of addresses, hardcoded string length.
* Depends on commiteth version as of 2017-06-10.
*/
* Bot that receives a POST request (from a GitHub issue comment webhook)
* and in case it's a comment that has "@autobounty <decimal> <currency>"
* awards that bounty to the address posted earlier in the thread (by the
* commiteth bot).
* TODO tests
* REVIEW parsing, non-persisting storage of addresses, hardcoded string length.
* Depends on commiteth version as of 2017-06-10.
*/
const config = require('./config');
const bot = require('./bot');
@ -35,8 +35,8 @@ app.post(`${config.urlEndpoint}`, jsonParser, function(req, res, next) {
//const to = bot.getAddress(req);
const amount = bot.getAmount(req);
const gasPrice = bot.getGasPrice();
console.log('amount: ', amount);
console.log('gasPrice: ', gasPrice);
bot.log('amount: ' + amount);
bot.log('gasPrice: ' + gasPrice);
/*
eth.getTransactionCount(address, (err, nonce) => {
eth.sendTransaction({

View File

@ -19,6 +19,7 @@
"express": "^4.15.2",
"helmet": "^3.9.0",
"lodash": "^4.17.4",
"web3": "^0.18.2"
"web3": "^0.18.2",
"winston": "^2.4.0"
}
}