Simplified logger example

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2024-09-12 11:14:21 +02:00
parent d8cea8fba1
commit 06ff90ba8c
2 changed files with 4 additions and 50 deletions
+3 -49
View File
@@ -181,55 +181,9 @@ class DebugConsole implements LoggingInterface {
Level? level,
StackTrace? stackTrace,
}) {
if (Feature.logging.disabled) return;
if (Feature.debugConsoleLogging.disabled) return;
final Map<String, dynamic> localMetadata = metadata ?? {};
final String? module = localMetadata["module"] as String?;
final String? method = localMetadata["method"] as String?;
const JsonEncoder encoder = JsonEncoder.withIndent(" ");
final String? prettyprint =
(localMetadata.isNotEmpty) ? encoder.convert(localMetadata) : null;
final Logger logger = Logger(
level: level,
printer: PrettyPrinter(
methodCount: 2,
errorMethodCount: kDebugMode &&
!(level == Level.error ||
level == Level.warning ||
level == Level.trace ||
level == Level.fatal)
? 4
: 8,
stackTraceBeginIndex: 1,
lineLength: 120,
colors: !Platform.isIOS,
printEmojis: kDebugMode,
dateTimeFormat: DateTimeFormat.none,
),
);
// Print the message to the debug console
String prefix = "";
if (module != null) prefix += "[$module]";
if (method != null) prefix += "[$method]";
if (prefix.isNotEmpty) prefix += " ";
message = "$prefix$message";
if (prettyprint.isNotNullOrEmpty) message += "\n\n$prettyprint";
localMetadata.removeWhere((key, value) => key == "module");
localMetadata.removeWhere((key, value) => key == "method");
localMetadata.removeWhere((key, value) => key == "filenameAndLineNumber");
logger.log(
level ?? Level.debug,
message,
error: localMetadata["error"] ?? "",
stackTrace: stackTrace,
debugPrint(
"$message\n"
"$metadata\n"
);
}
+1 -1
View File
@@ -1,6 +1,6 @@
name: arcane_framework
description: "The Arcane Framework provides a modular, feature-rich solution for bootstrapping new applications."
version: 1.0.1
version: 1.0.1+1
repository: https://github.com/hanskokx/arcane_framework
issue_tracker: https://github.com/hanskokx/arcane_framework/issues