build
This commit is contained in:
parent
3c8aa13a5e
commit
b5f932ab33
8 changed files with 25 additions and 14 deletions
|
|
@ -10,6 +10,7 @@ interface LogOptions {
|
|||
conta?: string
|
||||
usuario?: string
|
||||
detalhes?: unknown[]
|
||||
eProdicao: boolean
|
||||
}
|
||||
|
||||
interface LokiStream {
|
||||
|
|
@ -23,7 +24,12 @@ interface LokiStream {
|
|||
}
|
||||
|
||||
const createLogger = (level: LogLevel) => {
|
||||
const sendToLoki = async (message: string, options: LogOptions = {}) => {
|
||||
const sendToLoki = async (mensagem: string, options: LogOptions) => {
|
||||
if (!options.eProdicao) {
|
||||
console.log(level, mensagem, options)
|
||||
return
|
||||
}
|
||||
|
||||
const { app, conta, usuario, detalhes = [] } = options
|
||||
const timestamp = `${Date.now()}000000`
|
||||
|
||||
|
|
@ -31,8 +37,8 @@ const createLogger = (level: LogLevel) => {
|
|||
// Formata a linha de log principal
|
||||
const mainLog =
|
||||
detalhes.length > 0
|
||||
? `${message} | ${detalhes.map((d) => JSON.stringify(d)).join(" ")}`
|
||||
: message
|
||||
? `${mensagem} | ${detalhes.map((d) => JSON.stringify(d)).join(" ")}`
|
||||
: mensagem
|
||||
|
||||
const payload: LokiStream = {
|
||||
stream: { app, conta, usuario, level },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue