server: remove unused logger.store attribute
ci/woodpecker/push/lint-client Pipeline failed Details
ci/woodpecker/push/lint-backend Pipeline failed Details
ci/woodpecker/push/lint-sw Pipeline failed Details
ci/woodpecker/push/lint-foundkey-js Pipeline was successful Details
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/test Pipeline failed Details

This commit is contained in:
Johann150 2024-04-01 21:25:14 +02:00
parent f245b6e517
commit 095802d059
Signed by: Johann150
GPG Key ID: 9EE6577A2A06F8F1
7 changed files with 11 additions and 17 deletions

View File

@ -10,7 +10,7 @@ import { masterMain } from './master.js';
import { workerMain } from './worker.js';
const logger = new Logger('core');
const clusterLogger = logger.createSubLogger('cluster', false);
const clusterLogger = logger.createSubLogger('cluster');
const ev = new Xev();
/**

View File

@ -18,7 +18,7 @@ const _dirname = dirname(_filename);
const meta = JSON.parse(fs.readFileSync(`${_dirname}/../../../../built/meta.json`, 'utf-8'));
const logger = new Logger('core');
const bootLogger = logger.createSubLogger('boot', false);
const bootLogger = logger.createSubLogger('boot');
function greet(): void {
if (envOption.logLevel !== LOG_LEVELS.quiet) {

View File

@ -1,7 +1,7 @@
import Logger from '@/services/logger.js';
import config from './index.js';
const logger = new Logger('config:redis', false);
const logger = new Logger('config:redis');
function getRedisFamily(family?: string | number): number {
const familyMap = {

View File

@ -72,7 +72,7 @@ import { getRedisOptions } from '@/config/redis.js';
import { dbLogger } from './logger.js';
import { redisClient } from './redis.js';
const sqlLogger = dbLogger.createSubLogger('sql', false);
const sqlLogger = dbLogger.createSubLogger('sql');
class MyCustomLogger implements Logger {
private highlight(sql: string): string {

View File

@ -29,7 +29,7 @@ import proxyServer from './proxy/index.js';
import webServer from './web/index.js';
import { initializeStreamingServer } from './api/streaming.js';
export const serverLogger = new Logger('server', false);
export const serverLogger = new Logger('server');
// Init app
const app = new Koa();

View File

@ -12,7 +12,7 @@ import { getChartInsertLock } from '@/misc/app-lock.js';
import { db } from '@/db/postgre.js';
import Logger from '../logger.js';
const logger = new Logger('chart', process.env.NODE_ENV !== 'test');
const logger = new Logger('chart');
const columnPrefix = '___' as const;
const uniqueTempColumnPrefix = 'unique_temp___' as const;

View File

@ -11,7 +11,6 @@ export type Level = LOG_LEVELS[keyof LOG_LEVELS];
export default class Logger {
private domain: string;
private parentLogger: Logger | null = null;
private store: boolean;
/**
* Messages below this level will be discarded.
*/
@ -20,22 +19,19 @@ export default class Logger {
/**
* Create a logger instance.
* @param domain Logging domain
* @param store Whether to store messages
*/
constructor(domain: string, store = true, minLevel?: Level) {
constructor(domain: string, minLevel?: Level) {
this.domain = domain;
this.store = store;
this.minLevel = minLevel ?? envOption.logLevel;
}
/**
* Create a child logger instance.
* @param domain Logging domain
* @param store Whether to store messages
* @returns A Logger instance whose parent logger is this instance.
*/
public createSubLogger(domain: string, store = true, minLevel?: Level): Logger {
const logger = new Logger(domain, store, minLevel);
public createSubLogger(domain: string, minLevel?: Level): Logger {
const logger = new Logger(domain, minLevel);
logger.parentLogger = this;
return logger;
}
@ -47,16 +43,14 @@ export default class Logger {
* @param message The message to be logged.
* @param subDomains Names of sub-loggers to be added.
*/
private log(level: Level, message: string, subDomains: Domain[] = [], _store = true): void {
const store = _store && this.store;
private log(level: Level, message: string, subDomains: Domain[] = []): void {
// Check against the configured log level.
if (level < this.minLevel) return;
// If this logger has a parent logger, delegate the actual logging to it,
// so the parent domain(s) will be logged properly.
if (this.parentLogger) {
this.parentLogger.log(level, message, [this.domain].concat(subDomains), store);
this.parentLogger.log(level, message, [this.domain].concat(subDomains));
return;
}