From 45b6a6bc540ded964e80392637be1688a7a97b98 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 19 Apr 2018 18:03:46 +0900 Subject: [PATCH] make logger great again --- package.json | 2 ++ src/server/index.ts | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/package.json b/package.json index 1522e58269..3184c48846 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "@types/koa-bodyparser": "4.2.0", "@types/koa-compress": "^2.0.8", "@types/koa-favicon": "2.0.19", + "@types/koa-logger": "^3.1.0", "@types/koa-mount": "3.0.1", "@types/koa-multer": "1.0.0", "@types/koa-router": "7.0.27", @@ -141,6 +142,7 @@ "koa-compress": "3.0.0", "koa-favicon": "2.0.1", "koa-json-body": "^5.3.0", + "koa-logger": "^3.2.0", "koa-mount": "3.0.0", "koa-multer": "1.0.2", "koa-router": "7.4.0", diff --git a/src/server/index.ts b/src/server/index.ts index 5db3da2b93..2b5a910507 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -10,6 +10,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 activityPub from './activitypub'; import webFinger from './webfinger'; @@ -19,6 +20,12 @@ import config from '../config'; const app = new Koa(); app.proxy = true; +if (process.env.NODE_ENV != 'production') { + // Logger + app.use(logger()); +} + +// Compress response app.use(compress({ flush: zlib.constants.Z_SYNC_FLUSH }));