improve logs

This commit is contained in:
tdurieux
2021-04-21 22:38:49 +02:00
parent 963797121a
commit 4dca68c569
+7 -7
View File
@@ -23,7 +23,7 @@ async function anonymizeRepository(options) {
if (repoConfig.options.expirationMode != "never") { if (repoConfig.options.expirationMode != "never") {
if (repoConfig.options.expirationDate <= new Date()) { if (repoConfig.options.expirationDate <= new Date()) {
console.log("The repository is expired"); console.log(repoConfig.repoId, "The repository is expired");
await repoUtils.updateStatus(repoConfig, "expired"); await repoUtils.updateStatus(repoConfig, "expired");
await repoUtils.removeRepository(repoConfig); await repoUtils.removeRepository(repoConfig);
throw "repository_expired"; throw "repository_expired";
@@ -36,11 +36,11 @@ async function anonymizeRepository(options) {
yesterday.setDate(yesterday.getDate() - 1); yesterday.setDate(yesterday.getDate() - 1);
if (repoConfig.options.update && lastView < yesterday) { if (repoConfig.options.update && lastView < yesterday) {
console.log("check for updates in the repository."); console.log(repoConfig.repoId, "check for updates in the repository.");
try { try {
} catch (error) { } catch (error) {
console.error("Error while updating the repository."); console.error("Error while updating the repository.");
console.error(error); console.error(repoConfig.repoId, error);
} }
await repoUtils.updateAnonymizedRepository(repoConfig); await repoUtils.updateAnonymizedRepository(repoConfig);
} }
@@ -83,7 +83,7 @@ router.get("/:repoId/stats", async (req, res) => {
const stats = await fileUtils.getStats({ repoConfig }); const stats = await fileUtils.getStats({ repoConfig });
return res.json(stats.languages); return res.json(stats.languages);
} catch (error) { } catch (error) {
console.log(error); console.error(req.params.repoId, req.params.path, error);
return res.status(500).json({ error }); return res.status(500).json({ error });
} }
}); });
@@ -98,7 +98,7 @@ router.get("/:repoId/options", async (req, res) => {
await anonymizeRepository({ repoConfig }); await anonymizeRepository({ repoConfig });
} catch (error) { } catch (error) {
console.log("Error during the anonymization of the repository"); console.log("Error during the anonymization of the repository");
console.log(error); console.error(req.params.repoId, error);
} }
if (repoConfig.status == "removed") { if (repoConfig.status == "removed") {
throw "repository_expired"; throw "repository_expired";
@@ -115,7 +115,7 @@ router.get("/:repoId/options", async (req, res) => {
return res.json(repoConfig.options); return res.json(repoConfig.options);
} catch (error) { } catch (error) {
console.log(error); console.error(req.params.repoId, error);
return res.status(500).json({ error }); return res.status(500).json({ error });
} }
}); });
@@ -156,7 +156,7 @@ router.get("/:repoId/file/:path*", async (req, res) => {
return res.status(404).json({ error: "file_not_found" }); return res.status(404).json({ error: "file_not_found" });
} }
} catch (error) { } catch (error) {
console.error(error); console.error(req.params.repoId, req.params.path, error);
return res.status(500).send({ error }); return res.status(500).send({ error });
} }
}); });