fix: realtime log gatewway
This commit is contained in:
@@ -2,20 +2,16 @@
|
||||
import consola_, { FancyReporter, LogLevel } from 'consola'
|
||||
import { CronJob } from 'cron'
|
||||
import { createWriteStream } from 'fs'
|
||||
import { resolve } from 'path'
|
||||
import { argv } from 'zx-cjs'
|
||||
|
||||
import { CronExpression } from '@nestjs/schedule'
|
||||
|
||||
import { LOG_DIR } from '~/constants/path.constant'
|
||||
import { getTodayLogFilePath } from '~/utils/path.util'
|
||||
|
||||
import { redisSubPub } from '../utils/redis-subpub.util'
|
||||
import { getShortDate, getShortTime } from '../utils/time.util'
|
||||
import { getShortTime } from '../utils/time.util'
|
||||
import { isDev, isTest } from './env.global'
|
||||
|
||||
export const getTodayLogFilePath = () =>
|
||||
resolve(LOG_DIR, `stdout_${getShortDate(new Date())}.log`)
|
||||
|
||||
class Reporter extends FancyReporter {
|
||||
isInVirtualTerminal = typeof process.stdout.columns === 'undefined' // HACK: if got `undefined` that means in PM2 pty
|
||||
protected formatDate(date: Date): string {
|
||||
|
||||
@@ -24,10 +24,10 @@ import { ApiName } from '~/common/decorator/openapi.decorator'
|
||||
import { CRON_DESCRIPTION } from '~/constants/meta.constant'
|
||||
import { LOG_DIR } from '~/constants/path.constant'
|
||||
import { SCHEDULE_CRON_OPTIONS } from '~/constants/system.constant'
|
||||
import { getTodayLogFilePath } from '~/global/consola.global'
|
||||
import { CronService } from '~/processors/helper/helper.cron.service'
|
||||
import { TaskQueueService } from '~/processors/helper/helper.tq.service'
|
||||
import { formatByteSize } from '~/utils'
|
||||
import { getTodayLogFilePath } from '~/utils/path.util'
|
||||
|
||||
import { LogQueryDto, LogTypeDto } from './health.dto'
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import { LOG_DIR } from '~/constants/path.constant'
|
||||
import { JWTService } from '~/processors/helper/helper.jwt.service'
|
||||
import { CacheService } from '~/processors/redis/cache.service'
|
||||
import { SubPubBridgeService } from '~/processors/redis/subpub.service'
|
||||
import { getTodayLogFilePath } from '~/utils/path.util'
|
||||
|
||||
import { BusinessEvents } from '../../../constants/business-event.constant'
|
||||
import { AuthService } from '../../../modules/auth/auth.service'
|
||||
@@ -48,7 +49,6 @@ export class AdminEventsGateway
|
||||
|
||||
this.subscribeSocketToHandlerMap.set(client, handler)
|
||||
if (prevLog) {
|
||||
const { getTodayLogFilePath } = await import('~/global/consola.global')
|
||||
const stream = fs
|
||||
.createReadStream(resolve(LOG_DIR, getTodayLogFilePath()), {
|
||||
encoding: 'utf-8',
|
||||
|
||||
8
src/utils/path.util.ts
Normal file
8
src/utils/path.util.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { resolve } from 'path'
|
||||
|
||||
import { LOG_DIR } from '~/constants/path.constant'
|
||||
|
||||
import { getShortDate } from './time.util'
|
||||
|
||||
export const getTodayLogFilePath = () =>
|
||||
resolve(LOG_DIR, `stdout_${getShortDate(new Date())}.log`)
|
||||
Reference in New Issue
Block a user