.
This commit is contained in:
parent
25273beaed
commit
d1a7a364bd
1 changed files with 36 additions and 37 deletions
|
|
@ -40,50 +40,49 @@ type tipoLog = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const logger =
|
export const logger =
|
||||||
({ app, eProducao }: { app: string; eProducao: boolean }) =>
|
({ app: app_e, eProducao }: { app: string; eProducao: boolean }) =>
|
||||||
({ inquilino, usuario }: tipoOpSessao) =>
|
({ inquilino, usuario }: tipoOpSessao) =>
|
||||||
async (
|
async (
|
||||||
level: tipoLevel,
|
level: tipoLevel,
|
||||||
mensagem: string,
|
mensagem: string,
|
||||||
op_tipoLog?: tipoLog,
|
op_tipoLog?: tipoLog,
|
||||||
): Promise<[objeto: object, erro?: string]> => {
|
): Promise<[objeto: object, erro?: string]> => {
|
||||||
let { __filename, detalhes, local } = op_tipoLog || {}
|
let { __filename, detalhes, local } = op_tipoLog || {}
|
||||||
|
|
||||||
if (!eProducao) {
|
const app = `${eProducao ? '' : 'DEV-'}${app_e}`
|
||||||
app = `DEV-${app}`
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cwd && __filename) {
|
|
||||||
__filename = __filename.replace(cwd, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (local) {
|
if (cwd && __filename) {
|
||||||
detalhes = [`${nomeVariavel({ local })}="${local}"`]
|
__filename = __filename.replace(cwd, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__filename) {
|
if (local) {
|
||||||
detalhes = [`${nomeVariavel({ __filename })}="${__filename}"`]
|
detalhes = [`${nomeVariavel({ local })}="${local}"`]
|
||||||
}
|
}
|
||||||
|
|
||||||
const timestamp = `${Date.now()}000000`
|
if (__filename) {
|
||||||
|
detalhes = [`${nomeVariavel({ __filename })}="${__filename}"`]
|
||||||
|
}
|
||||||
|
|
||||||
const mainLog = detalhes?.length
|
const timestamp = `${Date.now()}000000`
|
||||||
? `${mensagem} | ${detalhes.map((d) => JSON.stringify(d)).join(" ")}`
|
|
||||||
: mensagem
|
|
||||||
|
|
||||||
const payload = {
|
const mainLog = detalhes?.length
|
||||||
stream: { app, inquilino, usuario, level },
|
? `${mensagem} | ${detalhes.map((d) => JSON.stringify(d)).join(" ")}`
|
||||||
values: [
|
: mensagem
|
||||||
[
|
|
||||||
timestamp,
|
|
||||||
mainLog, // Linha de log direta
|
|
||||||
],
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
const objeto = { streams: [payload] }
|
const payload = {
|
||||||
|
stream: { app, inquilino, usuario, level },
|
||||||
|
values: [
|
||||||
|
[
|
||||||
|
timestamp,
|
||||||
|
mainLog, // Linha de log direta
|
||||||
|
],
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
const response = await postLogger({ objeto })
|
const objeto = { streams: [payload] }
|
||||||
|
|
||||||
return response
|
const response = await postLogger({ objeto })
|
||||||
}
|
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue