Skip to content

Commit

Permalink
[mixin_logger] add onWriteToFile callback
Browse files Browse the repository at this point in the history
  • Loading branch information
boyan01 committed Feb 8, 2024
1 parent 1134cc0 commit 855d458
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
36 changes: 6 additions & 30 deletions packages/mixin_logger/example/pubspec.lock
Expand Up @@ -91,22 +91,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "04be76c4a4bb50f14904e64749237e541e7c7bcf7ec0b196907322ab5d2fc739"
url: "https://pub.dev"
source: hosted
version: "9.0.16"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: b06739349ec2477e943055aea30172c5c7000225f79dad4702e2ec0eda79a6ff
url: "https://pub.dev"
source: hosted
version: "1.0.5"
lints:
dependency: transitive
description:
Expand All @@ -127,18 +111,18 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.8.0"
version: "0.5.0"
meta:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.10.0"
mixin_logger:
dependency: "direct main"
description:
Expand Down Expand Up @@ -215,22 +199,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
version: "13.0.0"
web:
dependency: transitive
description:
name: web
sha256: edc8a9573dd8c5a83a183dae1af2b6fd4131377404706ca4e5420474784906fa
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
url: "https://pub.dev"
source: hosted
version: "0.4.0"
version: "0.3.0"
sdks:
dart: ">=3.2.0-194.0.dev <4.0.0"
flutter: ">=2.0.0"
3 changes: 3 additions & 0 deletions packages/mixin_logger/lib/mixin_logger.dart
Expand Up @@ -27,6 +27,8 @@ final _wtfPen = AnsiPen()..magenta();

final _writeToFile = platform.WriteToFileImpl();

void Function(String log)? onWriteToFile;

extension _LogLevelExtension on _LogLevel {
String get prefix {
switch (this) {
Expand Down Expand Up @@ -141,6 +143,7 @@ void _print(String message, _LogLevel level) {
final output = '${formatDateTime(DateTime.now())} ${level.prefix} $message';
if (logToFile && !kIsWeb) {
_writeToFile.writeLog(output);
onWriteToFile?.call(output);
}
if (kLogMode) {
// ignore: avoid_print
Expand Down

0 comments on commit 855d458

Please sign in to comment.