Compare commits
No commits in common. "726c76cf963d18786eed72a0027ec45580d0cf7d" and "1f386df256fcb215f6d7cff841dc238ba4428ed8" have entirely different histories.
726c76cf96
...
1f386df256
|
|
@ -1,12 +1,5 @@
|
|||
import { mkdirSync } from "node:fs"
|
||||
import { getConfig } from "../config"
|
||||
import { log } from "../log"
|
||||
|
||||
const crashLogDir = getConfig("dataDir")
|
||||
mkdirSync(crashLogDir, { recursive: true })
|
||||
|
||||
const crashLogPath = `${crashLogDir}/crash.log`
|
||||
|
||||
export const logCrash = async (error: unknown) => {
|
||||
try {
|
||||
const stack = error instanceof Error ? error.stack : ""
|
||||
|
|
@ -15,7 +8,7 @@ export const logCrash = async (error: unknown) => {
|
|||
const crashLog = `Spike crashed at ${new Date().toISOString()}:\n${message}\n${stack ?? ""}\n`
|
||||
|
||||
// overwrite the crash log file
|
||||
const file = Bun.file(crashLogPath)
|
||||
const file = Bun.file(`${process.env.DATA_DIR}/crash.log`)
|
||||
file.write(crashLog)
|
||||
} catch (writeError) {
|
||||
log({ type: "error", error: writeError, context: "writing crash log" })
|
||||
|
|
@ -40,7 +33,7 @@ export const alertAboutCrashLog = async (client: any) => {
|
|||
|
||||
const clearCrashLog = async () => {
|
||||
try {
|
||||
const file = Bun.file(crashLogPath)
|
||||
const file = Bun.file(`${process.env.DATA_DIR}/crash.log`)
|
||||
if (!(await file.exists())) return
|
||||
const contents = await file.text()
|
||||
await file.write("")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user