mirror of
https://github.com/hanskokx/arcane_framework.git
synced 2026-05-14 02:19:08 +02:00
Simplified logger example
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -181,55 +181,9 @@ class DebugConsole implements LoggingInterface {
|
|||||||
Level? level,
|
Level? level,
|
||||||
StackTrace? stackTrace,
|
StackTrace? stackTrace,
|
||||||
}) {
|
}) {
|
||||||
if (Feature.logging.disabled) return;
|
debugPrint(
|
||||||
if (Feature.debugConsoleLogging.disabled) return;
|
"$message\n"
|
||||||
|
"$metadata\n"
|
||||||
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,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
name: arcane_framework
|
name: arcane_framework
|
||||||
description: "The Arcane Framework provides a modular, feature-rich solution for bootstrapping new applications."
|
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
|
repository: https://github.com/hanskokx/arcane_framework
|
||||||
issue_tracker: https://github.com/hanskokx/arcane_framework/issues
|
issue_tracker: https://github.com/hanskokx/arcane_framework/issues
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user