From d55277e57e9c927cd29d3d55c366f3781c2396f6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 3 Feb 2019 02:01:06 +0900 Subject: [PATCH] Better logging --- src/server/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/server/index.ts b/src/server/index.ts index de77975fd..edb78f55f 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -11,7 +11,7 @@ import * as Koa from 'koa'; import * as Router from 'koa-router'; import * as mount from 'koa-mount'; import * as compress from 'koa-compress'; -import * as logger from 'koa-logger'; +import * as koaLogger from 'koa-logger'; import * as requestStats from 'request-stats'; //const slow = require('koa-slow'); @@ -22,6 +22,9 @@ import networkChart from '../chart/network'; import apiServer from './api'; import { sum } from '../prelude/array'; import User from '../models/user'; +import Logger from '../misc/logger'; + +const logger = new Logger('server'); // Init app const app = new Koa(); @@ -29,7 +32,9 @@ app.proxy = true; if (!['production', 'test'].includes(process.env.NODE_ENV)) { // Logger - app.use(logger()); + app.use(koaLogger(str => { + logger.info(str); + })); // Delay //app.use(slow({