Migrate issue.services to new logger

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-09-28 11:37:09 +01:00
parent 7a6dc186f3
commit d395b65512

View File

@ -1,6 +1,6 @@
/* eslint-disable no-useless-escape */
const axios = require("axios");
const log = require("../utils/logs.utils");
import { logger } from "../utils/logger.utils";
const issueLabels = {
bug: 120,
@ -11,7 +11,7 @@ const issueLabels = {
};
async function processor(data) {
log.out("issueService.processor: Issue received", "info");
logger.debug("issueService.processor: Issue received");
let out = {};
out.labels = [issueLabels[data?.label] || 0, issueLabels["web-user"]];
out.title = data?.subject.replace(/<[^>]+>|[\*\$]/g, "");
@ -31,10 +31,10 @@ async function sendToGitea(body) {
/* Need to read the output from the POST and pass the result upwards to the
client.*/
if (res.status == 201) {
log.out("issueService.sendToGitea: Issue sent to Gitea", "info");
logger.info("issueService.sendToGitea: Issue sent to Gitea");
return { status: res.status, message: "issue created" };
} else {
log.out(`issueService.sendToGitea: Fail to send issue: ${res.body}`, "err");
logger.error(res.body, "issueService.sendToGitea: Fail to send issue");
return { status: res.status, message: "issue not created" };
}
}