fix(gotransport): error handling so we dont get spammed with errors
This commit is contained in:
@@ -2,6 +2,7 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { pino } from "pino";
|
import { pino } from "pino";
|
||||||
import build from "pino-abstract-transport";
|
import build from "pino-abstract-transport";
|
||||||
|
import { tryCatch } from "../../globalUtils/tryCatch.js";
|
||||||
|
|
||||||
const pinoLogLevels: any = {
|
const pinoLogLevels: any = {
|
||||||
10: "trace",
|
10: "trace",
|
||||||
@@ -26,12 +27,19 @@ export default async function buildGoTransport() {
|
|||||||
// service: obj?.service.toLowerCase(),
|
// service: obj?.service.toLowerCase(),
|
||||||
// message: obj.msg,
|
// message: obj.msg,
|
||||||
// });
|
// });
|
||||||
|
const { data, error } = (await tryCatch(
|
||||||
|
axios.post(`${process.env.LST_BASE_URL}/api/v1/log`, {
|
||||||
|
service: obj?.service.toLowerCase(),
|
||||||
|
level: levelName,
|
||||||
|
message: obj.msg,
|
||||||
|
})
|
||||||
|
)) as any;
|
||||||
|
|
||||||
axios.post(`${process.env.LST_BASE_URL}/api/v1/log`, {
|
if (error) {
|
||||||
service: obj?.service.toLowerCase(),
|
console.log(
|
||||||
level: levelName,
|
"The go server must be offline so we cant post the new logs."
|
||||||
message: obj.msg,
|
);
|
||||||
});
|
}
|
||||||
|
|
||||||
// console.log(`Go log level: ${levelName}`);
|
// console.log(`Go log level: ${levelName}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user