This commit is contained in:
Luiz Silva 2025-02-22 18:23:50 -03:00
parent e2bb1b7ca2
commit d412131b3a
5 changed files with 22 additions and 46 deletions

View file

@ -19,6 +19,13 @@ export const postLogger = async ({
}
}
let cwd = ""
/** define a localização da pasta do projeto */
export const defineCwd = (novoCwd: string) => {
cwd = novoCwd
}
type tipoLevel = "info" | "warn" | "error"
type tipoOpSessao = {
@ -46,28 +53,8 @@ export const logger =
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) {