mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
Merge pull request #852 from Hexastack/851-issue---make-logger-part-of-the-base-repository
feat: centrelize logger
This commit is contained in:
@@ -6,8 +6,9 @@
|
||||
* 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 { NotFoundException } from '@nestjs/common';
|
||||
import { Inject, NotFoundException } from '@nestjs/common';
|
||||
|
||||
import { LoggerService } from '@/logger/logger.service';
|
||||
import { TFilterQuery } from '@/utils/types/filter.types';
|
||||
|
||||
import { DtoConfig } from '../types/dto.types';
|
||||
@@ -25,6 +26,9 @@ export abstract class BaseController<
|
||||
> {
|
||||
eventEmitter: typeof this.service.eventEmitter;
|
||||
|
||||
@Inject(LoggerService)
|
||||
readonly logger: LoggerService;
|
||||
|
||||
constructor(protected readonly service: BaseService<T, P, TFull, Dto>) {
|
||||
this.eventEmitter = service.eventEmitter;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
UpdateWriteOpResult,
|
||||
} from 'mongoose';
|
||||
|
||||
import { LoggerService } from '@/logger/logger.service';
|
||||
import { TFilterQuery } from '@/utils/types/filter.types';
|
||||
|
||||
import { PageQueryDto, QuerySortDto } from '../pagination/pagination-query.dto';
|
||||
@@ -83,6 +84,9 @@ export abstract class BaseRepository<
|
||||
@Inject(EventEmitter2)
|
||||
readonly eventEmitter: EventEmitter2;
|
||||
|
||||
@Inject(LoggerService)
|
||||
readonly logger: LoggerService;
|
||||
|
||||
constructor(
|
||||
readonly model: Model<T>,
|
||||
private readonly cls: new () => T,
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
* 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 { ConflictException } from '@nestjs/common';
|
||||
import { ConflictException, Inject } from '@nestjs/common';
|
||||
import { ClassTransformOptions } from 'class-transformer';
|
||||
import { MongoError } from 'mongodb';
|
||||
import { ProjectionType, QueryOptions } from 'mongoose';
|
||||
|
||||
import { LoggerService } from '@/logger/logger.service';
|
||||
import { TFilterQuery } from '@/utils/types/filter.types';
|
||||
|
||||
import { PageQueryDto, QuerySortDto } from '../pagination/pagination-query.dto';
|
||||
@@ -28,6 +29,9 @@ export abstract class BaseService<
|
||||
> {
|
||||
eventEmitter: typeof this.repository.eventEmitter;
|
||||
|
||||
@Inject(LoggerService)
|
||||
readonly logger: LoggerService;
|
||||
|
||||
constructor(protected readonly repository: BaseRepository<T, P, TFull, Dto>) {
|
||||
this.eventEmitter = repository.eventEmitter;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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:
|
||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||
@@ -10,6 +10,7 @@ import { Module } from '@nestjs/common';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
|
||||
import { LoggerService } from '@/logger/logger.service';
|
||||
import { installDummyFixtures } from '@/utils/test/fixtures/dummy';
|
||||
import { rootMongooseTestModule } from '@/utils/test/test';
|
||||
|
||||
@@ -22,6 +23,6 @@ import { DummyService } from './services/dummy.service';
|
||||
rootMongooseTestModule(installDummyFixtures),
|
||||
MongooseModule.forFeature([DummyModel]),
|
||||
],
|
||||
providers: [DummyRepository, DummyService, EventEmitter2],
|
||||
providers: [DummyRepository, DummyService, EventEmitter2, LoggerService],
|
||||
})
|
||||
export class DummyModule {}
|
||||
|
||||
Reference in New Issue
Block a user