mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
refactor(server): enhance the Logger usage (#9763)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { ConsoleLogger, Injectable, Scope } from '@nestjs/common';
|
||||
import { ConsoleLogger, Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable({
|
||||
scope: Scope.TRANSIENT,
|
||||
})
|
||||
// DO NOT use this Logger directly
|
||||
// Use it via this way: `private readonly logger = new Logger(MyService.name)`
|
||||
@Injectable()
|
||||
export class AFFiNELogger extends ConsoleLogger {}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { FactoryProvider } from '@nestjs/common';
|
||||
import { FactoryProvider, Logger } from '@nestjs/common';
|
||||
import { createTransport, Transporter } from 'nodemailer';
|
||||
import SMTPTransport from 'nodemailer/lib/smtp-transport';
|
||||
|
||||
import { Config } from '../config';
|
||||
import { AFFiNELogger } from '../logger';
|
||||
|
||||
export const MAILER_SERVICE = Symbol('MAILER_SERVICE');
|
||||
|
||||
@@ -15,9 +14,9 @@ export const MAILER: FactoryProvider<
|
||||
Transporter<SMTPTransport.SentMessageInfo> | undefined
|
||||
> = {
|
||||
provide: MAILER_SERVICE,
|
||||
useFactory: (config: Config, logger: AFFiNELogger) => {
|
||||
useFactory: (config: Config) => {
|
||||
if (config.mailer) {
|
||||
logger.setContext('Mailer');
|
||||
const logger = new Logger('Mailer');
|
||||
const auth = config.mailer.auth;
|
||||
if (auth && auth.user && !('pass' in auth)) {
|
||||
logger.warn(
|
||||
@@ -30,5 +29,5 @@ export const MAILER: FactoryProvider<
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
inject: [Config, AFFiNELogger],
|
||||
inject: [Config],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user