From bea165b856d88de211fb90e6df2524a4a26d5a07 Mon Sep 17 00:00:00 2001 From: Roscoe Rubin-Rottenberg Date: Fri, 5 Jun 2026 21:39:34 -0400 Subject: [PATCH] fix: log level --- lib/main.dart | 5 ++++- lib/src/core/utils/logging/logger.dart | 7 ++++++- lib/src/core/utils/logging/logger_factory.dart | 6 ++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index e287f5b..ad8f813 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; @@ -47,7 +48,9 @@ void main() async { /// Setup logging framework based on environment void _setupLogging() { - sl().setGlobalLogLevel(LogLevel.warning); + sl().setGlobalLogLevel( + kDebugMode ? LogLevel.debug : LogLevel.warning, + ); } /// Initialize auth repository and wait for it to be ready diff --git a/lib/src/core/utils/logging/logger.dart b/lib/src/core/utils/logging/logger.dart index 2dd46f2..7a01a00 100644 --- a/lib/src/core/utils/logging/logger.dart +++ b/lib/src/core/utils/logging/logger.dart @@ -15,7 +15,7 @@ class SparkLogger { _includeStackTrace = includeStackTrace; /// The minimum log level that will be output - final LogLevel _minLevel; + LogLevel _minLevel; /// List of log outputs final List _outputs; @@ -94,4 +94,9 @@ class SparkLogger { void clearOutputs() { _outputs.clear(); } + + /// Update the minimum level for this logger. + void setMinLevel(LogLevel level) { + _minLevel = level; + } } diff --git a/lib/src/core/utils/logging/logger_factory.dart b/lib/src/core/utils/logging/logger_factory.dart index e1b7c1f..63aa727 100644 --- a/lib/src/core/utils/logging/logger_factory.dart +++ b/lib/src/core/utils/logging/logger_factory.dart @@ -45,10 +45,12 @@ class LoggerFactory { /// Set the global minimum log level /// - /// This will affect all loggers created after this call. - /// Existing loggers will not be affected. + /// This affects both existing loggers and loggers created after this call. static void setGlobalLogLevel(LogLevel level) { _globalMinLevel = level; + for (final logger in _loggers.values) { + logger.setMinLevel(level); + } } /// Add a new default output -- 2.51.2