initialize method
Configures the logger if it has not been initialized.
This method should be used for the initial setup of the logger.
If the logger was auto-initialized (used before calling initialize()),
this will automatically replace the auto-configuration.
strategies - List of strategies to use for logging.
level - The minimum log level to log. Defaults to LogLevel.none.
useIsolates - Whether to use isolates for heavy operations. Defaults to true.
enablePerformanceMonitoring - Whether to enable performance monitoring. Defaults to true.
enableModernConsole - Whether to enable modern console formatting. Defaults to true.
projectName - Custom project name to display in the banner. If not provided, uses default.
showBanner - Whether to display the initialization banner. Defaults to true.
Implementation
Future<void> initialize({
List<LogStrategy>? strategies,
LogLevel level = LogLevel.none,
bool? useIsolates, // Made nullable to allow auto-detection
bool enablePerformanceMonitoring = true,
bool enableModernConsole = true,
bool force = false, // Allow re-initialization for testing
String? projectName,
bool showBanner = true,
}) async {
// Auto-detect platform support for isolates
final shouldUseIsolates = useIsolates ?? _isIsolateSupported();
// If auto-initialized, treat as force: true automatically
final shouldForce = force || _isAutoInitialized;
await logger._initialize(
strategies: strategies,
level: level,
force: shouldForce,
useIsolates: shouldUseIsolates,
enablePerformanceMonitoring: enablePerformanceMonitoring,
enableModernConsole: enableModernConsole,
projectName: projectName,
showBanner: showBanner,
);
}