mirror of
https://github.com/hexastack/hexabot
synced 2025-05-31 10:57:06 +00:00
fix: logger ctx
This commit is contained in:
parent
ae4bfcfe89
commit
f52c82e82a
@ -108,7 +108,7 @@ describe('AttachmentController', () => {
|
|||||||
|
|
||||||
helperService = module.get<HelperService>(HelperService);
|
helperService = module.get<HelperService>(HelperService);
|
||||||
settingService = module.get<SettingService>(SettingService);
|
settingService = module.get<SettingService>(SettingService);
|
||||||
loggerService = module.get<LoggerService>(LoggerService);
|
loggerService = await module.resolve<LoggerService>(LoggerService);
|
||||||
|
|
||||||
helperService.register(
|
helperService.register(
|
||||||
new LocalStorageHelper(settingService, helperService, loggerService),
|
new LocalStorageHelper(settingService, helperService, loggerService),
|
||||||
|
@ -1,11 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Hexastack. All rights reserved.
|
* Copyright © 2025 Hexastack. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||||
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ConsoleLogger } from '@nestjs/common';
|
import { ConsoleLogger, Inject, Injectable, Scope } from '@nestjs/common';
|
||||||
|
import { INQUIRER } from '@nestjs/core';
|
||||||
|
|
||||||
export class LoggerService extends ConsoleLogger {}
|
@Injectable({ scope: Scope.TRANSIENT })
|
||||||
|
export class LoggerService extends ConsoleLogger {
|
||||||
|
constructor(@Inject(INQUIRER) private parentClass: object) {
|
||||||
|
super(parentClass.constructor.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -101,10 +101,11 @@ async function bootstrap() {
|
|||||||
app.useWebSocketAdapter(redisIoAdapter);
|
app.useWebSocketAdapter(redisIoAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
process.on('uncaughtException', (error) => {
|
process.on('uncaughtException', async (error) => {
|
||||||
if (error.stack?.toLowerCase().includes('smtp'))
|
if (error.stack?.toLowerCase().includes('smtp')) {
|
||||||
app.get(LoggerService).error('SMTP error', error.stack);
|
const logger = await app.resolve(LoggerService);
|
||||||
else throw error;
|
logger.error('SMTP error', error.stack);
|
||||||
|
} else throw error;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!isProduction) {
|
if (!isProduction) {
|
||||||
|
@ -37,7 +37,7 @@ import { UserSeeder } from './user/seeds/user.seed';
|
|||||||
import { userModels } from './user/seeds/user.seed-model';
|
import { userModels } from './user/seeds/user.seed-model';
|
||||||
|
|
||||||
export async function seedDatabase(app: INestApplicationContext) {
|
export async function seedDatabase(app: INestApplicationContext) {
|
||||||
const logger = app.get(LoggerService);
|
const logger = await app.resolve(LoggerService);
|
||||||
const modelSeeder = app.get(ModelSeeder);
|
const modelSeeder = app.get(ModelSeeder);
|
||||||
const categorySeeder = app.get(CategorySeeder);
|
const categorySeeder = app.get(CategorySeeder);
|
||||||
const contextVarSeeder = app.get(ContextVarSeeder);
|
const contextVarSeeder = app.get(ContextVarSeeder);
|
||||||
|
Loading…
Reference in New Issue
Block a user