Добавлено логирование работы методов

This commit is contained in:
Pavel Gnedov 2024-12-09 15:08:36 +07:00
parent 9c8bea0289
commit 299d658979

View file

@ -13,28 +13,32 @@ export type Report = {
@Injectable() @Injectable()
export class DailyEccmV2ReportService { export class DailyEccmV2ReportService {
// TODO: apply logger for all methods
private logger = new Logger(DailyEccmV2ReportService.name); private logger = new Logger(DailyEccmV2ReportService.name);
private jobs: any[] = []; private jobs: any[] = [];
addJob(job: any) { addJob(job: any) {
this.logger.log(`Adding job ${job.id}`);
this.jobs.push(job); this.jobs.push(job);
} }
getJobs() { getJobs() {
this.logger.log('Getting all jobs');
return this.jobs; return this.jobs;
} }
getJob(jobId: string) { getJob(jobId: string) {
this.logger.log(`Getting job ${jobId}`);
return this.jobs.find((job) => job.id === jobId); return this.jobs.find((job) => job.id === jobId);
} }
removeJob(jobId: string) { removeJob(jobId: string) {
this.logger.log(`Removing job ${jobId}`);
this.jobs.splice(this.jobs.indexOf(jobId), 1); this.jobs.splice(this.jobs.indexOf(jobId), 1);
} }
startAllJobs() { startAllJobs() {
this.logger.log('Starting all jobs');
this.jobs.forEach((job) => { this.jobs.forEach((job) => {
job.start(); job.start();
}); });
@ -43,11 +47,13 @@ export class DailyEccmV2ReportService {
startJob(jobId: string) { startJob(jobId: string) {
const job = this.getJob(jobId); const job = this.getJob(jobId);
if (job) { if (job) {
this.logger.log(`Starting job ${jobId}`);
job.start(); job.start();
} }
} }
stopAllJobs() { stopAllJobs() {
this.logger.log('Stopping all jobs');
this.jobs.forEach((job) => { this.jobs.forEach((job) => {
job.stop(); job.stop();
}); });
@ -56,6 +62,7 @@ export class DailyEccmV2ReportService {
stopJob(jobId: string) { stopJob(jobId: string) {
const job = this.getJob(jobId); const job = this.getJob(jobId);
if (job) { if (job) {
this.logger.log(`Stopping job ${jobId}`);
job.stop(); job.stop();
} }
} }