Extract code
This commit is contained in:
parent
e351a77f75
commit
580985c7be
|
@ -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 pino, { LoggerOptions } from "pino"
|
||||||
import path from "path"
|
import pinoPretty from "pino-pretty"
|
||||||
import fs from "fs"
|
|
||||||
import * as rfs from "rotating-file-stream"
|
|
||||||
|
|
||||||
import { IdentityType } from "@budibase/types"
|
import { IdentityType } from "@budibase/types"
|
||||||
|
|
||||||
|
@ -10,8 +8,7 @@ import * as context from "../../context"
|
||||||
import * as correlation from "../correlation"
|
import * as correlation from "../correlation"
|
||||||
import { LOG_CONTEXT } from "../index"
|
import { LOG_CONTEXT } from "../index"
|
||||||
|
|
||||||
import { budibaseTempDir } from "../../objectStore"
|
import { localFileDestination } from "../localLogging"
|
||||||
import pinoPretty from "pino-pretty"
|
|
||||||
|
|
||||||
// LOGGER
|
// LOGGER
|
||||||
|
|
||||||
|
@ -71,20 +68,6 @@ if (!env.DISABLE_PINO_LOGGER) {
|
||||||
return typeof obj === "string"
|
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
|
* Backwards compatibility between console logging statements
|
||||||
* and pino logging requirements.
|
* and pino logging requirements.
|
||||||
|
|
Loading…
Reference in New Issue