build
This commit is contained in:
parent
79a83fe158
commit
e1d94a75bd
8 changed files with 27 additions and 16 deletions
|
|
@ -20,7 +20,11 @@ type tipoLog = {
|
|||
export const logger =
|
||||
({ app, eProducao }: { app: string; eProducao: boolean }) =>
|
||||
({ inquilino, usuario }: tipoOpSessao) =>
|
||||
async (level: tipoLevel, mensagem: string, op_tipoLog?: tipoLog) => {
|
||||
async (
|
||||
level: tipoLevel,
|
||||
mensagem: string,
|
||||
op_tipoLog?: tipoLog,
|
||||
): Promise<[objeto: object, erro?: string]> => {
|
||||
let { __filename, detalhes, local } = op_tipoLog || {}
|
||||
|
||||
if (!eProducao) {
|
||||
|
|
@ -54,13 +58,16 @@ export const logger =
|
|||
],
|
||||
}
|
||||
|
||||
const objeto = { streams: [payload] }
|
||||
|
||||
const response = await crossFetch(`${LOKI_BASE_URL}${LOKI_ENDPOINT}`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ streams: [payload] }),
|
||||
})
|
||||
|
||||
body: JSON.stringify(objeto),
|
||||
}).catch((a) => a)
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erro ${response.status}: ${await response.text()}`)
|
||||
return [objeto, `Erro ${response.status}: ${await response?.text?.()}`]
|
||||
}
|
||||
|
||||
return [objeto]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,5 +7,7 @@ const lg = l({
|
|||
usuario: "pedrinho",
|
||||
})
|
||||
|
||||
lg("error", "Deu Ruim")
|
||||
lg("info", "Deu Bom", { __filename })
|
||||
lg("error", "Deu Ruim").then((a) => console.log(JSON.stringify(a)))
|
||||
lg("info", "Deu Bom", { __filename }).then((a) =>
|
||||
console.log(JSON.stringify(a)),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue