Skip to content

Commit dd2ef00

Browse files
committed
refactor(logger): improve log message formatting and structure
- Consolidate log message construction using a StringBuffer - Format error and stack trace information consistently - Enhance readability of log output by structuring the message
1 parent 06ffd3b commit dd2ef00

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/bootstrap.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,20 @@ Future<Widget> bootstrap(
4343
Logger.root.level = environment == app_config.AppEnvironment.production
4444
? Level.INFO
4545
: Level.ALL;
46+
4647
Logger.root.onRecord.listen((record) {
47-
print(
48+
final message = StringBuffer(
4849
'${record.level.name}: ${record.time}: ${record.loggerName}: ${record.message}',
4950
);
5051
if (record.error != null) {
51-
print('Error: ${record.error}');
52+
message.write('\nError: ${record.error}');
5253
}
5354
if (record.stackTrace != null) {
54-
print('Stack Trace: ${record.stackTrace}');
55+
message.write('\nStack Trace: ${record.stackTrace}');
5556
}
57+
print(message.toString());
5658
});
59+
5760
final logger = Logger('bootstrap');
5861
logger.config('--- Starting Bootstrap Process ---');
5962
logger.config('App Environment: $environment');

0 commit comments

Comments
 (0)