UNPKG

3.4 kBJavaScriptView Raw
1"use strict";
2/*
3 * MIT License
4 *
5 * Copyright (c) 2019 nest-mods
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
25Object.defineProperty(exports, "__esModule", { value: true });
26const tslib_1 = require("tslib");
27var WinstonLoggerService_1;
28/*
29 * Created by Diluka on 2019-02-15.
30 *
31 *
32 * ----------- 神 兽 佑 我 -----------
33 * ┏┓ ┏┓+ +
34 * ┏┛┻━━━━━━┛┻┓ + +
35 * ┃ ┃
36 * ┣ ━ ┃ ++ + + +
37 * ████━████ ┃+
38 * ┃ ┃ +
39 * ┃ ┴ ┃
40 * ┃ ┃ + +
41 * ┗━┓ ┏━┛ Code is far away from bug
42 * ┃ ┃ with the animal protecting
43 * ┃ ┃ + + + +
44 * ┃ ┃
45 * ┃ ┃ +
46 * ┃ ┃ + +
47 * ┃ ┃ +
48 * ┃ ┗━━━┓ + +
49 * ┃ ┣┓
50 * ┃ ┏┛
51 * ┗┓┓┏━━━━┳┓┏┛ + + + +
52 * ┃┫┫ ┃┫┫
53 * ┗┻┛ ┗┻┛+ + + +
54 * ----------- 永 无 BUG ------------
55 */
56const common_1 = require("@nestjs/common");
57const _ = require("lodash");
58const winston_util_1 = require("../util/winston.util");
59let WinstonLoggerService = WinstonLoggerService_1 = class WinstonLoggerService {
60 constructor() {
61 }
62 static getInstance() {
63 if (!this.instance) {
64 this.instance = new WinstonLoggerService_1();
65 }
66 return this.instance;
67 }
68 error(message, trace, context) {
69 winston_util_1.getLogger(context).log(Object.assign({ level: 'error' }, this.processMessage(message), { trace }));
70 }
71 log(message, context) {
72 winston_util_1.getLogger(context).log(Object.assign({ level: 'info' }, this.processMessage(message)));
73 }
74 warn(message, context) {
75 winston_util_1.getLogger(context).log(Object.assign({ level: 'warn' }, this.processMessage(message)));
76 }
77 processMessage(message) {
78 return _.isObject(message) ? message : { message };
79 }
80};
81WinstonLoggerService = WinstonLoggerService_1 = tslib_1.__decorate([
82 common_1.Injectable(),
83 tslib_1.__metadata("design:paramtypes", [])
84], WinstonLoggerService);
85exports.WinstonLoggerService = WinstonLoggerService;
86//# sourceMappingURL=winston-logger.service.js.map
\No newline at end of file