.
This commit is contained in:
parent
e2bb1b7ca2
commit
d412131b3a
5 changed files with 22 additions and 46 deletions
31
dist/logger.js
vendored
31
dist/logger.js
vendored
|
|
@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.logger = exports.postLogger = void 0;
|
||||
exports.logger = exports.defineCwd = 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";
|
||||
|
|
@ -22,32 +22,19 @@ const postLogger = async ({ objeto, }) => {
|
|||
}
|
||||
};
|
||||
exports.postLogger = postLogger;
|
||||
let cwd = "";
|
||||
/** define a localização da pasta do projeto */
|
||||
const defineCwd = (novoCwd) => {
|
||||
cwd = novoCwd;
|
||||
};
|
||||
exports.defineCwd = defineCwd;
|
||||
const logger = ({ app, eProducao }) => ({ inquilino, usuario }) => async (level, mensagem, op_tipoLog) => {
|
||||
let { __filename, detalhes, local } = op_tipoLog || {};
|
||||
if (!eProducao) {
|
||||
app = `DEV-${app}`;
|
||||
}
|
||||
const isNode = () => {
|
||||
try {
|
||||
return (typeof process !== "undefined" &&
|
||||
process.versions?.node &&
|
||||
!process.versions.electron);
|
||||
}
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
try {
|
||||
if (isNode() && typeof __filename !== "undefined") {
|
||||
// Modifica apenas se estiver em Node.js e as variáveis existirem
|
||||
__filename = __filename.replace(process.cwd(), "");
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
// Ignora erros de variáveis não definidas no navegador
|
||||
if (!(error instanceof ReferenceError)) {
|
||||
throw error;
|
||||
}
|
||||
if (cwd && __filename) {
|
||||
__filename = __filename.replace(cwd, "");
|
||||
}
|
||||
if (local) {
|
||||
detalhes = [`${(0, variaveisComuns_1.nomeVariavel)({ local })}="${local}"`];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue