mirror of
https://github.com/stonith404/pingvin-share.git
synced 2025-01-15 01:14:27 -05:00
refactor: improve logging
This commit is contained in:
parent
98c0de78e8
commit
2dc0fc9332
2 changed files with 17 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
||||||
import { Injectable } from "@nestjs/common";
|
import { Injectable, Logger } from "@nestjs/common";
|
||||||
import { Cron } from "@nestjs/schedule";
|
import { Cron } from "@nestjs/schedule";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as moment from "moment";
|
import * as moment from "moment";
|
||||||
|
@ -9,6 +9,8 @@ import { SHARE_DIRECTORY } from "../constants";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class JobsService {
|
export class JobsService {
|
||||||
|
private readonly logger = new Logger(JobsService.name);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private prisma: PrismaService,
|
private prisma: PrismaService,
|
||||||
private reverseShareService: ReverseShareService,
|
private reverseShareService: ReverseShareService,
|
||||||
|
@ -35,8 +37,9 @@ export class JobsService {
|
||||||
await this.fileService.deleteAllFiles(expiredShare.id);
|
await this.fileService.deleteAllFiles(expiredShare.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expiredShares.length > 0)
|
if (expiredShares.length > 0) {
|
||||||
console.log(`job: deleted ${expiredShares.length} expired shares`);
|
this.logger.log(`Deleted ${expiredShares.length} expired shares`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cron("0 * * * *")
|
@Cron("0 * * * *")
|
||||||
|
@ -51,11 +54,12 @@ export class JobsService {
|
||||||
await this.reverseShareService.remove(expiredReverseShare.id);
|
await this.reverseShareService.remove(expiredReverseShare.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expiredReverseShares.length > 0)
|
if (expiredReverseShares.length > 0) {
|
||||||
console.log(
|
this.logger.log(
|
||||||
`job: deleted ${expiredReverseShares.length} expired reverse shares`
|
`Deleted ${expiredReverseShares.length} expired reverse shares`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Cron("0 0 * * *")
|
@Cron("0 0 * * *")
|
||||||
deleteTemporaryFiles() {
|
deleteTemporaryFiles() {
|
||||||
|
@ -86,7 +90,7 @@ export class JobsService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`job: deleted ${filesDeleted} temporary files`);
|
this.logger.log(`Deleted ${filesDeleted} temporary files`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cron("0 * * * *")
|
@Cron("0 * * * *")
|
||||||
|
@ -108,7 +112,8 @@ export class JobsService {
|
||||||
const deletedTokensCount =
|
const deletedTokensCount =
|
||||||
refreshTokenCount + loginTokenCount + resetPasswordTokenCount;
|
refreshTokenCount + loginTokenCount + resetPasswordTokenCount;
|
||||||
|
|
||||||
if (deletedTokensCount > 0)
|
if (deletedTokensCount > 0) {
|
||||||
console.log(`job: deleted ${deletedTokensCount} expired refresh tokens`);
|
this.logger.log(`Deleted ${deletedTokensCount} expired refresh tokens`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,10 +116,9 @@ const TextPreview = () => {
|
||||||
const [text, setText] = useState<string | null>(null);
|
const [text, setText] = useState<string | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
api.get(`/shares/${shareId}/files/${fileId}?download=false`).then((res) => {
|
api
|
||||||
console.log(res.data);
|
.get(`/shares/${shareId}/files/${fileId}?download=false`)
|
||||||
setText(res.data);
|
.then((res) => setText(res.data));
|
||||||
});
|
|
||||||
}, [shareId, fileId]);
|
}, [shareId, fileId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Add table
Reference in a new issue