Skip to content

Commit ad7c499

Browse files
committed
+Update _shortenedLocation function
1 parent db8cc2c commit ad7c499

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/src/log.dart

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,13 +582,17 @@ String? _shortenedLocation(String? location) {
582582
if (location == null) {
583583
return null;
584584
}
585-
// Remove 'package:' prefix
586-
var cleaned = location.replaceFirst(RegExp(r'^package:[^\/]+\/'), '');
587-
// Remove column number (e.g., ':123' at the end)
588-
cleaned = cleaned.replaceFirst(RegExp(r':\d+$'), '');
589-
return cleaned.trim();
585+
final parts = location.split(RegExp(r'\s+'));
586+
final path = parts.first;
587+
final line = parts.last.split(':').first;
588+
final file = path.split('/').last.replaceAll('.dart', '');
589+
if (path.startsWith('package:')) {
590+
final package = path.split(':')[1].split('/').first;
591+
return '$package:$file #$line';
592+
} else {
593+
return '$file #$line';
594+
}
590595
}
591-
592596
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
593597

594598
enum _IconCategory {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repository: https://github.com/robmllze/df_log
1616
funding:
1717
- https://www.buymeacoffee.com/dev_cetera
1818
description: A package that provides logging utilities for better debugging.
19-
version: 0.3.15
19+
version: 0.3.16
2020
topics:
2121
- console
2222
- debugging

0 commit comments

Comments
 (0)