diff --git a/package.json b/package.json index 7a6486c..099c33c 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,8 @@ "ora": "^1.3.0", "request": "^2.81.0", "request-promise": "^4.2.1", - "winston": "^2.3.1" + "winston": "^2.3.1", + "winston-stream": "^0.0.0" }, "devDependencies": { "babel-cli": "^6.5.1", diff --git a/server/controllers/lighthouse.js b/server/controllers/lighthouse.js index c5cd8ea..f07c0ad 100644 --- a/server/controllers/lighthouse.js +++ b/server/controllers/lighthouse.js @@ -1,10 +1,18 @@ import 'babel-polyfill'; import winston from 'winston'; +import winstonStream from 'winston-stream'; import { sync, getStats } from '../utils/importer'; import elasticsearch from 'elasticsearch'; + +const loggerStream = winstonStream(winston, 'info'); + const eclient = new elasticsearch.Client({ host: 'http://elastic:changeme@localhost:9200', - log : 'info', + log : { + level : 'info', + type : 'stream', + stream: loggerStream, + }, }); function getSuggestions (input) { diff --git a/server/index.js b/server/index.js index b5c11fd..0d5530f 100644 --- a/server/index.js +++ b/server/index.js @@ -8,7 +8,7 @@ import winston from 'winston'; // Setup logging winston.remove(winston.transports.Console); -winston.add(winston.transports.Console, {colorize: true}); +winston.add(winston.transports.Console, { colorize: true, timestamp: true, prettyPrint: true }); // Create Koa Application const app = new Koa(); diff --git a/server/utils/importer/index.js b/server/utils/importer/index.js index 04012fd..1116fba 100644 --- a/server/utils/importer/index.js +++ b/server/utils/importer/index.js @@ -3,10 +3,20 @@ */ const bitcoin = require('bitcoin-promise'); const elasticsearch = require('elasticsearch'); -var eclient = new elasticsearch.Client({ +const winston = require('winston'); +const winstonStream = require('winston-stream'); + +const loggerStream = winstonStream(winston, 'info'); + +const eclient = new elasticsearch.Client({ host: 'http://elastic:changeme@localhost:9200', - log : 'info', + log : { + level : 'info', + type : 'stream', + stream: loggerStream, + }, }); + const client = new bitcoin.Client({ host : 'localhost', port : 9245, diff --git a/yarn.lock b/yarn.lock index 4f14d63..7a2924c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3546,6 +3546,10 @@ wide-align@^1.1.0: dependencies: string-width "^1.0.2" +winston-stream@^0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/winston-stream/-/winston-stream-0.0.0.tgz#9cd21c9828f688f184768e3fd53254140dca663c" + winston@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/winston/-/winston-2.3.1.tgz#0b48420d978c01804cf0230b648861598225a119"