mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-29 18:09:05 +01:00
reduce log spam from charts
This commit is contained in:
parent
41536480ce
commit
0f6d26e065
2 changed files with 11 additions and 4 deletions
|
@ -6,6 +6,8 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { ChartLoggerService } from '@/core/chart/ChartLoggerService.js';
|
||||
import Logger from '@/logger.js';
|
||||
import FederationChart from './charts/federation.js';
|
||||
import NotesChart from './charts/notes.js';
|
||||
import UsersChart from './charts/users.js';
|
||||
|
@ -24,6 +26,7 @@ import type { OnApplicationShutdown } from '@nestjs/common';
|
|||
export class ChartManagementService implements OnApplicationShutdown {
|
||||
private charts;
|
||||
private saveIntervalId: NodeJS.Timeout;
|
||||
private readonly logger: Logger;
|
||||
|
||||
constructor(
|
||||
private federationChart: FederationChart,
|
||||
|
@ -38,6 +41,7 @@ export class ChartManagementService implements OnApplicationShutdown {
|
|||
private perUserFollowingChart: PerUserFollowingChart,
|
||||
private perUserDriveChart: PerUserDriveChart,
|
||||
private apRequestChart: ApRequestChart,
|
||||
private chartLoggerService: ChartLoggerService,
|
||||
) {
|
||||
this.charts = [
|
||||
this.federationChart,
|
||||
|
@ -53,6 +57,7 @@ export class ChartManagementService implements OnApplicationShutdown {
|
|||
this.perUserDriveChart,
|
||||
this.apRequestChart,
|
||||
];
|
||||
this.logger = chartLoggerService.logger;
|
||||
}
|
||||
|
||||
@bindThis
|
||||
|
@ -62,6 +67,7 @@ export class ChartManagementService implements OnApplicationShutdown {
|
|||
for (const chart of this.charts) {
|
||||
chart.save();
|
||||
}
|
||||
this.logger.info('All charts saved');
|
||||
}, 1000 * 60 * 20);
|
||||
}
|
||||
|
||||
|
@ -72,6 +78,7 @@ export class ChartManagementService implements OnApplicationShutdown {
|
|||
await Promise.all(
|
||||
this.charts.map(chart => chart.save()),
|
||||
);
|
||||
this.logger.info('All charts saved');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -368,7 +368,7 @@ export default abstract class Chart<T extends Schema> {
|
|||
// 初期ログデータを作成
|
||||
data = this.getNewLog(null);
|
||||
|
||||
this.logger.info(`${this.name + (group ? `:${group}` : '')}(${span}): Initial commit created`);
|
||||
this.logger.debug(`${this.name + (group ? `:${group}` : '')}(${span}): Initial commit created`);
|
||||
}
|
||||
|
||||
const date = Chart.dateToTimestamp(current);
|
||||
|
@ -398,7 +398,7 @@ export default abstract class Chart<T extends Schema> {
|
|||
...columns,
|
||||
}) as RawRecord<T>;
|
||||
|
||||
this.logger.info(`${this.name + (group ? `:${group}` : '')}(${span}): New commit created`);
|
||||
this.logger.debug(`${this.name + (group ? `:${group}` : '')}(${span}): New commit created`);
|
||||
|
||||
return log;
|
||||
} finally {
|
||||
|
@ -418,7 +418,7 @@ export default abstract class Chart<T extends Schema> {
|
|||
@bindThis
|
||||
public async save(): Promise<void> {
|
||||
if (this.buffer.length === 0) {
|
||||
this.logger.info(`${this.name}: Write skipped`);
|
||||
this.logger.debug(`${this.name}: Write skipped`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -519,7 +519,7 @@ export default abstract class Chart<T extends Schema> {
|
|||
.execute(),
|
||||
]);
|
||||
|
||||
this.logger.info(`${this.name + (logHour.group ? `:${logHour.group}` : '')}: Updated`);
|
||||
this.logger.debug(`${this.name + (logHour.group ? `:${logHour.group}` : '')}: Updated`);
|
||||
|
||||
// TODO: この一連の処理が始まった後に新たにbufferに入ったものは消さないようにする
|
||||
this.buffer = this.buffer.filter(q => q.group != null && (q.group !== logHour.group));
|
||||
|
|
Loading…
Reference in a new issue