Decorate service

This commit is contained in:
Adria Navarro 2023-07-05 16:51:42 +02:00
parent b0f2306c50
commit e351a77f75
2 changed files with 8 additions and 6 deletions

View File

@ -75,7 +75,7 @@ function getPackageJsonFields(): {
const parsedContent = JSON.parse(content) const parsedContent = JSON.parse(content)
return { return {
VERSION: parsedContent.version, VERSION: parsedContent.version,
SERVICE_NAME: parsedContent.name.replace(/@budibase\//, ""), SERVICE_NAME: parsedContent.name,
} }
} catch { } catch {
// throwing an error here is confusing/causes backend-core to be hard to import // throwing an error here is confusing/causes backend-core to be hard to import
@ -168,6 +168,7 @@ const environment = {
// @ts-ignore // @ts-ignore
environment[key] = value environment[key] = value
}, },
ROLLING_LOG_MAX_SIZE: process.env.ROLLING_LOG_MAX_SIZE || "100M",
} }
// clean up any environment variable edge cases // clean up any environment variable edge cases

View File

@ -24,7 +24,9 @@ if (!env.DISABLE_PINO_LOGGER) {
return { level: label.toUpperCase() } return { level: label.toUpperCase() }
}, },
bindings: () => { bindings: () => {
return {} return {
service: env.SERVICE_NAME,
}
}, },
}, },
timestamp: () => `,"timestamp":"${new Date(Date.now()).toISOString()}"`, timestamp: () => `,"timestamp":"${new Date(Date.now()).toISOString()}"`,
@ -36,8 +38,7 @@ if (!env.DISABLE_PINO_LOGGER) {
destinations.push(pinoPretty({ singleLine: true })) destinations.push(pinoPretty({ singleLine: true }))
} }
// TODO if (env.SELF_HOSTED) {
if (true) {
destinations.push(localFileDestination()) destinations.push(localFileDestination())
} }
@ -71,9 +72,9 @@ if (!env.DISABLE_PINO_LOGGER) {
} }
function localFileDestination() { function localFileDestination() {
const fileName = path.join(budibaseTempDir(), "logs", `budibase.logs`) const fileName = path.join(budibaseTempDir(), `budibase.logs`)
const outFile = rfs.createStream(fileName, { const outFile = rfs.createStream(fileName, {
size: "10M", size: env.ROLLING_LOG_MAX_SIZE,
teeToStdout: true, teeToStdout: true,
}) })