- Improved automatic metadata detection in `ArcaneLogger`

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2025-01-23 13:59:40 +01:00
parent 6ffb83e59d
commit beee74e49a
4 changed files with 19 additions and 12 deletions
+4
View File
@@ -1,3 +1,7 @@
## 1.2.5
- Improved automatic metadata detection in `ArcaneLogger`
## 1.2.4 ## 1.2.4
- Update package dependencies - Update package dependencies
+1 -1
View File
@@ -14,7 +14,7 @@ dependencies:
uuid: ^4.5.0 uuid: ^4.5.0
dev_dependencies: dev_dependencies:
flutter_lints: ^4.0.0 flutter_lints: ^5.0.0
flutter_test: flutter_test:
sdk: flutter sdk: flutter
+13 -10
View File
@@ -132,22 +132,25 @@ class ArcaneLogger {
metadata.putIfAbsent("timestamp", () => now); metadata.putIfAbsent("timestamp", () => now);
try { try {
final List<String> parts = StackTrace.current final List<String> parts =
StackTrace.current.toString().split("\n")[2].split(RegExp("#2"))[1].trimLeft().split(".");
module ??= parts.first.replaceFirst("new ", "");
method ??= parts[1].split(" ").first.replaceAll("<anonymous", "");
final List<String> fileAndLineParts = StackTrace.current
.toString() .toString()
.split("\n")[2] .split("\n")[2]
.split(RegExp("#2"))[1] .split(RegExp("#2"))[1]
.trimLeft() .trim()
.split("."); .split("(package:")
.last
.split(":");
module ??= parts.first.replaceFirst("new ", ""); final String fileAndLine = "${fileAndLineParts[0]}:${fileAndLineParts[1]}";
method ??= parts[1].split(" ").first;
final String line = parts.last.substring(5).replaceAll(")", "");
final String file = parts[1].split(" ").last.replaceAll("(package:", "");
final String fileAndLine = "$file:$line";
metadata.putIfAbsent("module", () => module!); metadata.putIfAbsent("module", () => module!);
metadata.putIfAbsent("method", () => method!); if (method.isNotNullOrEmpty) metadata.putIfAbsent("method", () => method!);
metadata.putIfAbsent("filenameAndLineNumber", () => fileAndLine); metadata.putIfAbsent("filenameAndLineNumber", () => fileAndLine);
} catch (_) {} } catch (_) {}
+1 -1
View File
@@ -1,6 +1,6 @@
name: arcane_framework name: arcane_framework
description: "Agnostic Reusable Component Architecture for New Ecosystems: a modern framework for bootstrapping new applications" description: "Agnostic Reusable Component Architecture for New Ecosystems: a modern framework for bootstrapping new applications"
version: 1.2.4 version: 1.2.5
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