ログをデータベースに保存して管理画面で見れるように

This commit is contained in:
syuilo 2019-03-02 18:51:59 +09:00
parent f3ceb32a7c
commit 977af0a24d
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
29 changed files with 326 additions and 99 deletions

17
src/models/log.ts Normal file
View file

@ -0,0 +1,17 @@
import * as mongo from 'mongodb';
import db from '../db/mongodb';
const Log = db.get<ILog>('logs');
Log.createIndex('createdAt', { expireAfterSeconds: 3600 * 24 * 3 });
export default Log;
export interface ILog {
_id: mongo.ObjectID;
createdAt: Date;
machine: string;
worker: string;
domain: string[];
level: string;
message: string;
data: any;
}