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