FIX. Исправление времени логов на utc
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import * as mongoose from 'mongoose';
|
||||
import * as lodash from 'lodash';
|
||||
import * as moment from 'moment';
|
||||
|
||||
import {Injectable, NestInterceptor, ExecutionContext, CallHandler} from '@nestjs/common';
|
||||
import {Observable} from 'rxjs';
|
||||
@ -26,7 +27,7 @@ const saveLog = (
|
||||
response: any,
|
||||
startTime: string,
|
||||
) => {
|
||||
const endTime = new Date().toJSON();
|
||||
const endTime = moment().utc().format();
|
||||
const error = new ErrorModel({
|
||||
type,
|
||||
request: request,
|
||||
@ -40,7 +41,7 @@ const saveLog = (
|
||||
@Injectable()
|
||||
export class LoggingInterceptor implements NestInterceptor {
|
||||
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
|
||||
const start = new Date().toJSON();
|
||||
const start = moment().utc().format();
|
||||
const args = context.getArgs()?.[0] ?? {};
|
||||
const {headers, url, method, body} = args;
|
||||
const request = {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import * as mongoose from 'mongoose';
|
||||
import * as moment from 'moment';
|
||||
|
||||
import {Logger as DefaultLogger} from '@nestjs/common';
|
||||
import {MONGO_URL, LOG_TYPE} from 'src/consts';
|
||||
@ -23,7 +24,7 @@ const errorSchema = new mongoose.Schema({
|
||||
const ErrorModel = mongoose.model(LOG_TYPE.SERVER, errorSchema);
|
||||
|
||||
const saveError = (type: string, message: string, trace = '') => {
|
||||
const date = new Date().toJSON();
|
||||
const date = moment().utc().format();
|
||||
const error = new ErrorModel({
|
||||
type, message, trace, date
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user