This commit is contained in:
Luiz Silva 2025-02-21 17:58:21 -03:00
parent decb819207
commit 36d3cc6aa4
5 changed files with 25 additions and 8 deletions

9
dist/logger.js vendored
View file

@ -5,17 +5,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.logger = void 0;
const cross_fetch_1 = __importDefault(require("cross-fetch"));
const variaveisComuns_1 = require("./variaveisComuns");
const LOKI_BASE_URL = "https://log.idz.one";
const LOKI_ENDPOINT = "/loki/api/v1/push";
const logger = ({ app, eProducao }) => ({ inquilino, usuario }) => {
const f = (level) => async (mensagem, op_tipoLog) => {
let { __filename, detalhes } = op_tipoLog || {};
let { __filename, detalhes, local } = op_tipoLog || {};
if (!eProducao) {
app = `DEV-${app}`;
}
if (__filename && typeof process != "undefined" && process.cwd()) {
__filename = __filename.replace(process.cwd(), "");
}
if (local) {
detalhes = [`${(0, variaveisComuns_1.nomeVariavel)({ local })}="${local}"`];
}
if (__filename) {
detalhes = [`${(0, variaveisComuns_1.nomeVariavel)({ __filename })}="${__filename}"`];
}
const timestamp = `${Date.now()}000000`;
const mainLog = detalhes?.length
? `${mensagem} | ${detalhes.map((d) => JSON.stringify(d)).join(" ")}`