diff --git a/yarn-project/aztec/src/logging.ts b/yarn-project/aztec/src/logging.ts index cd5fef656b0..d59cd9b33cd 100644 --- a/yarn-project/aztec/src/logging.ts +++ b/yarn-project/aztec/src/logging.ts @@ -1,4 +1,4 @@ -import { onLog, setLevel } from '@aztec/foundation/log'; +import { currentLevel, onLog, setLevel } from '@aztec/foundation/log'; import * as path from 'path'; import * as process from 'process'; @@ -55,7 +55,7 @@ function createWinstonJsonStdoutLogger( return info; }); return winston.createLogger({ - level: process.env.LOG_LEVEL ?? 'info', + level: currentLevel, transports: [ new winston.transports.Console({ format: format.combine(format.timestamp(), ignoreAztecPattern(), format.json()), diff --git a/yarn-project/foundation/src/log/logger.ts b/yarn-project/foundation/src/log/logger.ts index 9a0dd25cd4f..b3fe598e897 100644 --- a/yarn-project/foundation/src/log/logger.ts +++ b/yarn-project/foundation/src/log/logger.ts @@ -4,15 +4,20 @@ import { inspect } from 'util'; import { type LogData, type LogFn } from './log_fn.js'; const LogLevels = ['silent', 'error', 'warn', 'info', 'verbose', 'debug'] as const; -const DefaultLogLevel = process.env.NODE_ENV === 'test' ? ('silent' as const) : ('info' as const); /** * A valid log severity level. */ export type LogLevel = (typeof LogLevels)[number]; -const envLogLevel = process.env.LOG_LEVEL?.toLowerCase() as LogLevel; -export let currentLevel = LogLevels.includes(envLogLevel) ? envLogLevel : DefaultLogLevel; +function getLogLevel() { + const envLogLevel = process.env.LOG_LEVEL?.toLowerCase() as LogLevel; + const defaultNonTestLogLevel = process.env.DEBUG === undefined ? ('info' as const) : ('debug' as const); + const defaultLogLevel = process.env.NODE_ENV === 'test' ? ('silent' as const) : defaultNonTestLogLevel; + return LogLevels.includes(envLogLevel) ? envLogLevel : defaultLogLevel; +} + +export let currentLevel = getLogLevel(); const namespaces = process.env.DEBUG ?? 'aztec:*'; debug.enable(namespaces);