diff --git a/cyberwow/lib/config.dart b/cyberwow/lib/config.dart
index 51050dd..631ac9f 100644
--- a/cyberwow/lib/config.dart
+++ b/cyberwow/lib/config.dart
@@ -19,9 +19,13 @@ along with CyberWOW. If not, see .
*/
+import 'package:logging/logging.dart';
+
import 'config/prototype.dart';
import 'config/cyberwow.dart' as cryptoConfig;
+final Logger log = new Logger('Default');
+
const config = cryptoConfig.config;
const arch = 'arm64';
@@ -29,3 +33,4 @@ const arch = 'arm64';
const minimumHeight = 118361;
const isPC = arch == 'x86_64';
+
diff --git a/cyberwow/lib/controller/syncing.dart b/cyberwow/lib/controller/syncing.dart
index e1abefc..eea5949 100644
--- a/cyberwow/lib/controller/syncing.dart
+++ b/cyberwow/lib/controller/syncing.dart
@@ -56,7 +56,7 @@ Stream runBinary (String name) async* {
"--non-interactive",
] + extraArgs + config.extraArgs;
- print('args: ' + args.toString());
+ log.info('args: ' + args.toString());
final outputProcess = await Process.start(newPath, args);
await for (var line in outputProcess.stdout.transform(utf8.decoder)) {
@@ -64,5 +64,6 @@ Stream runBinary (String name) async* {
}
// the app should never reach here
+ log.severe('Daemon is gone!');
exit(1);
}
diff --git a/cyberwow/lib/main.dart b/cyberwow/lib/main.dart
index 34290c8..8caf158 100644
--- a/cyberwow/lib/main.dart
+++ b/cyberwow/lib/main.dart
@@ -21,6 +21,8 @@ along with CyberWOW. If not, see .
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
+import 'package:flutter/foundation.dart';
+import 'package:logging/logging.dart';
import 'dart:io';
import 'dart:async';
@@ -35,9 +37,15 @@ import 'widget/syncing.dart';
import 'widget/synced.dart';
import 'widget/resyncing.dart';
-void main() => runApp(MyApp());
+void main() {
+ Logger.root.level = kReleaseMode ? Level.INFO : Level.ALL;
+ Logger.root.onRecord.listen((LogRecord rec) {
+ print('${rec.level.name}: ${rec.time}: ${rec.message}');
+ });
+ runApp(CyberWOW_App());
+}
-class MyApp extends StatelessWidget {
+class CyberWOW_App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp
@@ -47,20 +55,20 @@ class MyApp extends StatelessWidget {
(
primarySwatch: Colors.purple,
),
- home: MyHomePage(title: 'CyberWOW'),
+ home: CyberWOW_Page(title: 'CyberWOW'),
);
}
}
-class MyHomePage extends StatefulWidget {
- MyHomePage({Key key, this.title}) : super(key: key);
+class CyberWOW_Page extends StatefulWidget {
+ CyberWOW_Page({Key key, this.title}) : super(key: key);
final String title;
@override
- _MyHomePageState createState() => _MyHomePageState();
+ _CyberWOW_PageState createState() => _CyberWOW_PageState();
}
-class _MyHomePageState extends State with WidgetsBindingObserver
+class _CyberWOW_PageState extends State with WidgetsBindingObserver
{
int _counter = 0;
// AppState _state = LoadingState("init...");
@@ -70,7 +78,7 @@ class _MyHomePageState extends State with WidgetsBindingObserver
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
- // print('app cycle: ${state}');
+ log.fine('app cycle: ${state}');
setState(() { _notification = state; });
}
@@ -97,7 +105,7 @@ class _MyHomePageState extends State with WidgetsBindingObserver
void _updateLoading(LoadingState state, String msg) {
- print('updateLoading: ' + msg);
+ log.fine('updateLoading: ' + msg);
}
Future buildStateMachine(BlankState _blankState) async {
@@ -132,7 +140,7 @@ class _MyHomePageState extends State with WidgetsBindingObserver
@override
void initState() {
super.initState();
- print("MyHomePageState initState");
+ log.fine("CyberWOW_PageState initState");
WidgetsBinding.instance.addObserver(this);
@@ -145,7 +153,7 @@ class _MyHomePageState extends State with WidgetsBindingObserver
}
Future _exitApp(BuildContext context) async {
- print("MyHomePageState _exitApp");
+ log.info("CyberWOW_PageState _exitApp");
WidgetsBinding.instance.removeObserver(this);
exit(0);
}
diff --git a/cyberwow/lib/state.dart b/cyberwow/lib/state.dart
index c05af0a..f6f63b7 100644
--- a/cyberwow/lib/state.dart
+++ b/cyberwow/lib/state.dart
@@ -112,10 +112,10 @@ class LoadingState extends HookedState {
}
Future load() async {
- print("Loading next");
+ log.fine("Loading next");
await for (var line in loadingProgress) {
// append(line);
- print(line);
+ log.info(line);
}
}
@@ -145,7 +145,7 @@ class SyncingState extends HookedState {
}
Future next(Stream processOutput) async {
- print("Syncing next");
+ log.fine("Syncing next");
Future printStdout() async {
await for (var line in processOutput) {
@@ -155,7 +155,7 @@ class SyncingState extends HookedState {
append(line);
- print(line);
+ log.info(line);
}
}
@@ -180,7 +180,7 @@ class SyncingState extends HookedState {
printStdout();
await checkSync();
- print('syncing: loop exit');
+ log.fine('syncing: loop exit');
final _height = await rpc.height();
SyncedState _next = SyncedState(setState, getNotification, stdout, processOutput);
@@ -200,14 +200,14 @@ class SyncedState extends HookedState {
SyncedState(f, s, this.stdout, this.processOutput) : super (f, s);
Future next() async {
- print("Synced next");
+ log.fine("Synced next");
Future logStdout() async {
await for (var line in processOutput) {
if (!synced) break;
// print('synced: print stdout loop');
stdout += line;
- print(line);
+ log.info(line);
}
}
@@ -228,7 +228,7 @@ class SyncedState extends HookedState {
await checkSync();
- print('synced: loop exit');
+ log.fine('synced: loop exit');
ReSyncingState _next = ReSyncingState(setState, getNotification, stdout, processOutput);
setState(_next);
@@ -250,14 +250,14 @@ class ReSyncingState extends HookedState {
}
Future next() async {
- print("ReSyncing next");
+ log.fine("ReSyncing next");
Future printStdout() async {
await for (var line in processOutput) {
if (synced) break;
// print('re-syncing: print stdout loop');
append(line);
- print(line);
+ log.info(line);
}
}
@@ -275,7 +275,7 @@ class ReSyncingState extends HookedState {
printStdout();
await checkSync();
- print('resync: await exit');
+ log.fine('resync: await exit');
SyncedState _next = SyncedState(setState, getNotification, stdout, processOutput);
_next.height = await rpc.height();
setState(_next);
diff --git a/cyberwow/pubspec.lock b/cyberwow/pubspec.lock
index c1aa87d..1f4f0d8 100644
--- a/cyberwow/pubspec.lock
+++ b/cyberwow/pubspec.lock
@@ -1,5 +1,5 @@
# Generated by pub
-# See https://www.dartlang.org/tools/pub/glossary#lockfile
+# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
@@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
- version: "2.1.0"
+ version: "2.2.0"
boolean_selector:
dependency: transitive
description:
@@ -60,6 +60,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.3"
+ logging:
+ dependency: "direct main"
+ description:
+ name: logging
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.11.3+2"
matcher:
dependency: transitive
description:
@@ -94,14 +101,14 @@ packages:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
- version: "1.5.0"
+ version: "1.7.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.2"
+ version: "2.0.3"
sky_engine:
dependency: transitive
description: flutter
@@ -148,7 +155,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
- version: "0.2.4"
+ version: "0.2.5"
typed_data:
dependency: transitive
description:
@@ -164,5 +171,5 @@ packages:
source: hosted
version: "2.0.8"
sdks:
- dart: ">=2.2.0 <3.0.0"
+ dart: ">=2.2.2 <3.0.0"
flutter: ">=0.1.4 <2.0.0"
diff --git a/cyberwow/pubspec.yaml b/cyberwow/pubspec.yaml
index cf7faf3..01aeaf7 100644
--- a/cyberwow/pubspec.yaml
+++ b/cyberwow/pubspec.yaml
@@ -25,6 +25,7 @@ dependencies:
cupertino_icons: ^0.1.2
path_provider: ^1.1.0
http: ^0.12.0
+ logging: ^0.11.3
dev_dependencies:
flutter_test: