melhorias em log
This commit is contained in:
parent
e1d94a75bd
commit
505f64f70b
5 changed files with 39 additions and 21 deletions
27
dist/logger.js
vendored
27
dist/logger.js
vendored
|
|
@ -3,11 +3,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.logger = void 0;
|
||||
exports.logger = exports.postLogger = 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 postLogger = async ({ objeto, }) => {
|
||||
const response = await (0, cross_fetch_1.default)(`${LOKI_BASE_URL}${LOKI_ENDPOINT}`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(objeto),
|
||||
}).catch((a) => a);
|
||||
if (!response.ok) {
|
||||
return [objeto, `Erro ${response.status}: ${await response?.text?.()}`];
|
||||
}
|
||||
else {
|
||||
return [objeto];
|
||||
}
|
||||
};
|
||||
exports.postLogger = postLogger;
|
||||
const logger = ({ app, eProducao }) => ({ inquilino, usuario }) => async (level, mensagem, op_tipoLog) => {
|
||||
let { __filename, detalhes, local } = op_tipoLog || {};
|
||||
if (!eProducao) {
|
||||
|
|
@ -36,15 +50,8 @@ const logger = ({ app, eProducao }) => ({ inquilino, usuario }) => async (level,
|
|||
],
|
||||
};
|
||||
const objeto = { streams: [payload] };
|
||||
const response = await (0, cross_fetch_1.default)(`${LOKI_BASE_URL}${LOKI_ENDPOINT}`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(objeto),
|
||||
}).catch((a) => a);
|
||||
if (!response.ok) {
|
||||
return [objeto, `Erro ${response.status}: ${await response?.text?.()}`];
|
||||
}
|
||||
return [objeto];
|
||||
const response = await (0, exports.postLogger)({ objeto });
|
||||
return response;
|
||||
};
|
||||
exports.logger = logger;
|
||||
//# sourceMappingURL=logger.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue