Skip to content

Commit

Permalink
separated examples code completely
Browse files Browse the repository at this point in the history
  • Loading branch information
git-elliot committed Nov 9, 2023
1 parent 55979d8 commit fde01e1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion example/host_scan.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:logging/logging.dart';
import 'package:network_tools/network_tools.dart';
import '../lib/src/network_tools_utils.dart';
import '../example/lib/example_utils.dart';

Future<void> main() async {
enableExampleLogging();
Expand Down
15 changes: 15 additions & 0 deletions example/lib/example_utils.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:logging/logging.dart';

final examplesLog = Logger("network_tools_examples");

void enableExampleLogging() {
Logger.root.level = Level.FINE;
Logger.root.onRecord.listen((record) {
if (record.loggerName == examplesLog.name) {
// ignore: avoid_print
print(
'${record.time.toLocal()}: ${record.level.name}: ${record.loggerName}: ${record.message}',
);
}
});
}
2 changes: 1 addition & 1 deletion example/mdns_scan.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:network_tools/network_tools.dart';
import '../lib/src/network_tools_utils.dart';
import '../example/lib/example_utils.dart';

Future<void> main() async {
enableExampleLogging();
Expand Down
2 changes: 1 addition & 1 deletion example/port_scan.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:logging/logging.dart';
import '../lib/src/network_tools_utils.dart';
import 'package:network_tools/network_tools.dart';
import '../example/lib/example_utils.dart';

Future<void> main() async {
enableExampleLogging();
Expand Down
13 changes: 0 additions & 13 deletions lib/src/network_tools_utils.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
import 'package:logging/logging.dart';

final log = Logger("network_tools");
final examplesLog = Logger("network_tools_examples");

void enableExampleLogging() {
Logger.root.level = Level.FINE;
Logger.root.onRecord.listen((record) {
if (record.loggerName == examplesLog.name) {
// ignore: avoid_print
print(
'${record.time.toLocal()}: ${record.level.name}: ${record.loggerName}: ${record.message}',
);
}
});
}

0 comments on commit fde01e1

Please sign in to comment.