Extract code
This commit is contained in:
parent
e351a77f75
commit
580985c7be
2 changed files with 22 additions and 19 deletions
20
packages/backend-core/src/logging/localLogging.ts
Normal file
20
packages/backend-core/src/logging/localLogging.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import fs from "fs"
|
||||
import path from "path"
|
||||
import * as rfs from "rotating-file-stream"
|
||||
|
||||
import { env } from "process"
|
||||
import { budibaseTempDir } from "src/objectStore"
|
||||
|
||||
export function localFileDestination() {
|
||||
const fileName = path.join(budibaseTempDir(), `budibase.logs`)
|
||||
const outFile = rfs.createStream(fileName, {
|
||||
size: env.ROLLING_LOG_MAX_SIZE,
|
||||
teeToStdout: true,
|
||||
})
|
||||
|
||||
outFile.on("rotation", () => {
|
||||
fs.copyFileSync(fileName, `${fileName}.bak`)
|
||||
})
|
||||
|
||||
return outFile
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
import pino, { LoggerOptions } from "pino"
|
||||
import path from "path"
|
||||
import fs from "fs"
|
||||
import * as rfs from "rotating-file-stream"
|
||||
import pinoPretty from "pino-pretty"
|
||||
|
||||
import { IdentityType } from "@budibase/types"
|
||||
|
||||
|
@ -10,8 +8,7 @@ import * as context from "../../context"
|
|||
import * as correlation from "../correlation"
|
||||
import { LOG_CONTEXT } from "../index"
|
||||
|
||||
import { budibaseTempDir } from "../../objectStore"
|
||||
import pinoPretty from "pino-pretty"
|
||||
import { localFileDestination } from "../localLogging"
|
||||
|
||||
// LOGGER
|
||||
|
||||
|
@ -71,20 +68,6 @@ if (!env.DISABLE_PINO_LOGGER) {
|
|||
return typeof obj === "string"
|
||||
}
|
||||
|
||||
function localFileDestination() {
|
||||
const fileName = path.join(budibaseTempDir(), `budibase.logs`)
|
||||
const outFile = rfs.createStream(fileName, {
|
||||
size: env.ROLLING_LOG_MAX_SIZE,
|
||||
teeToStdout: true,
|
||||
})
|
||||
|
||||
outFile.on("rotation", () => {
|
||||
fs.copyFileSync(fileName, `${fileName}.bak`)
|
||||
})
|
||||
|
||||
return outFile
|
||||
}
|
||||
|
||||
/**
|
||||
* Backwards compatibility between console logging statements
|
||||
* and pino logging requirements.
|
||||
|
|
Loading…
Reference in a new issue