mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-02 18:09:58 +08:00
fix(server): disable winston in seflhost instance (#9585)
This commit is contained in:
@@ -1,30 +1,6 @@
|
||||
import { LoggingWinston } from '@google-cloud/logging-winston';
|
||||
import { ConsoleLogger, LoggerService, Provider, Scope } from '@nestjs/common';
|
||||
import { createLogger, transports } from 'winston';
|
||||
import { ConsoleLogger, Injectable, Scope } from '@nestjs/common';
|
||||
|
||||
import { Config } from '../config';
|
||||
import { AFFiNELogger } from './logger';
|
||||
|
||||
export const loggerProvider: Provider<LoggerService> = {
|
||||
provide: AFFiNELogger,
|
||||
useFactory: (config: Config) => {
|
||||
if (config.NODE_ENV !== 'production') {
|
||||
return new ConsoleLogger();
|
||||
}
|
||||
const loggingWinston = new LoggingWinston();
|
||||
// Create a Winston logger that streams to Cloud Logging
|
||||
const instance = createLogger({
|
||||
level: config.affine.stable ? 'log' : 'verbose',
|
||||
transports: [
|
||||
new transports.Console(),
|
||||
// Add Cloud Logging
|
||||
loggingWinston,
|
||||
],
|
||||
});
|
||||
return new AFFiNELogger(instance);
|
||||
},
|
||||
inject: [Config],
|
||||
// use transient to make sure the logger is created for each di context
|
||||
// to make the `setContext` method works as expected
|
||||
@Injectable({
|
||||
scope: Scope.TRANSIENT,
|
||||
};
|
||||
})
|
||||
export class AFFiNELogger extends ConsoleLogger {}
|
||||
|
||||
Reference in New Issue
Block a user