Skip to content

Commit

Permalink
Updated logging parameters
Browse files Browse the repository at this point in the history
- Changed yamlparser to let RUST_LOG override the LoggingLevel going to the yaml parser
- Added LOGGING_LEVEL and LOGGING_LEVEL_CONSOLE to comply with environement variable standards while keeping backwards compatibility
  • Loading branch information
tkmcmaster committed Nov 22, 2024
1 parent 5d0f9ec commit 0d59ba6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions common/src/util/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { join as pathJoin } from "path";
export { LogLevel } ;

export const config = {
LogFileName: process.env.LogFileName || "ppaas-common",
LoggingLevel: process.env.LoggingLevel as Logger.LogLevel || "info",
LoggingLevelConsole: process.env.LoggingLevelConsole as Logger.LogLevel || "warn",
LogFileName: process.env.LOG_FILE_NAME || process.env.LogFileName || "ppaas-common",
LoggingLevel: process.env.LOGGING_LEVEL as Logger.LogLevel || process.env.LoggingLevel as Logger.LogLevel || "info",
LoggingLevelConsole: process.env.LOGGING_LEVEL_CONSOLE as Logger.LogLevel || process.env.LoggingLevelConsole as Logger.LogLevel || "warn",
LogFileLocation: process.env.LOG_FILE_LOCATION || "."
};

Expand Down
6 changes: 4 additions & 2 deletions common/src/yamlparser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ export class YamlParser {
config = new Config(
fileBuffer,
varMap,
typeof logConfig.LoggingLevel === "number" ? undefined : logConfig.LoggingLevel
// TODO: Add version checker
// If RUST_LOG is set use that, otherwise use LoggingLevel
process.env.RUST_LOG || (typeof logConfig.LoggingLevel === "number"
? undefined
: logConfig.LoggingLevel)
);
yamlValid = true;
} catch (error: unknown) {
Expand Down
4 changes: 2 additions & 2 deletions controller/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const nextConfig = {
distDir: "dist",
// env: {} // env variables are set at build time, not run time. They are better optimized during the build process
publicRuntimeConfig: { // These are sent to the client and the server and are set at run time
LoggingLevel: process.env.LoggingLevel,
LOGGING_LEVEL: process.env.LOGGING_LEVEL || process.env.LoggingLevel,
APPLICATION_NAME: process.env.APPLICATION_NAME,
SYSTEM_NAME: process.env.SYSTEM_NAME,
FS_SITE: process.env.FS_SITE,
Expand Down Expand Up @@ -135,7 +135,7 @@ const nextConfig = {
},
// https://github.com/vercel/next.js/discussions/11493#discussioncomment-14606
env: { // These are sent to the client and the server and are set at build time for static pages
LoggingLevel: process.env.LoggingLevel || "", // Only checks if debug
LOGGING_LEVEL: process.env.LOGGING_LEVEL || process.env.LoggingLevel || "", // Only checks if debug
// @ts-ignore
APPLICATION_NAME: process.env.APPLICATION_NAME,
// @ts-ignore
Expand Down

0 comments on commit 0d59ba6

Please sign in to comment.