Skip to content

Commit

Permalink
feat: logging to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
alienc0der committed Jun 20, 2023
1 parent abd1e0f commit 8166496
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 37 deletions.
22 changes: 18 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:layout/layout.dart';
import 'package:local_notifier/local_notifier.dart';
import 'package:logging/logging.dart';
import 'package:overlay_support/overlay_support.dart';
import 'package:path/path.dart' as path;
import 'package:provider/provider.dart';
import 'package:tray_manager/tray_manager.dart';
import 'package:window_manager/window_manager.dart';
Expand All @@ -36,19 +37,32 @@ main() async {
Provider.debugCheckInvalidValueType = null;
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;

ensureDirectoriesExist();
Hive.init(znnDefaultPaths.cache.path.toString());

// Setup logger
Directory syriusLogDir =
Directory(path.join(znnDefaultCacheDirectory.path, 'log'));
if (!syriusLogDir.existsSync()) {
syriusLogDir.createSync(recursive: true);
}
final logFile = File(
'${syriusLogDir.path}${path.separator}syrius-${DateTime.now().millisecondsSinceEpoch}.log');
Logger.root.level = Level.ALL;
Logger.root.onRecord.listen((record) {
Logger.root.onRecord.listen((LogRecord record) {
if (kDebugMode) {
print(
'${record.level.name} ${record.loggerName} ${record.message} ${record.time}: '
'${record.error} ${record.stackTrace}\n');
}
logFile.writeAsString(
'${record.level.name} ${record.loggerName} ${record.message} ${record.time}: '
'${record.error} ${record.stackTrace}\n',
mode: FileMode.append,
flush: true,
);
});

ensureDirectoriesExist();
Hive.init(znnDefaultPaths.cache.path.toString());

windowManager.ensureInitialized();
await windowManager.setPreventClose(true);

Expand Down
72 changes: 40 additions & 32 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ packages:
dependency: transitive
description:
name: args
sha256: c372bb384f273f0c2a8aaaa226dad84dc27c8519a691b888725dec59518ad53a
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
url: "https://pub.dev"
source: hosted
version: "2.4.1"
version: "2.4.2"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -173,18 +173,18 @@ packages:
dependency: "direct dev"
description:
name: build_runner
sha256: "220ae4553e50d7c21a17c051afc7b183d28a24a420502e842f303f8e4e6edced"
sha256: "5e1929ad37d48bd382b124266cb8e521de5548d406a45a5ae6656c13dab73e37"
url: "https://pub.dev"
source: hosted
version: "2.4.4"
version: "2.4.5"
build_runner_core:
dependency: transitive
description:
name: build_runner_core
sha256: "88a57f2ac99849362e73878334caa9f06ee25f31d2adced882b8337838c84e1e"
sha256: "6d6ee4276b1c5f34f21fdf39425202712d2be82019983d52f351c94aafbc2c41"
url: "https://pub.dev"
source: hosted
version: "7.2.9"
version: "7.2.10"
built_collection:
dependency: transitive
description:
Expand All @@ -197,10 +197,10 @@ packages:
dependency: transitive
description:
name: built_value
sha256: "7dd62d9faf105c434f3d829bbe9c4be02ec67f5ed94832222116122df67c5452"
sha256: "598a2a682e2a7a90f08ba39c0aaa9374c5112340f0a2e275f61b59389543d166"
url: "https://pub.dev"
source: hosted
version: "8.6.0"
version: "8.6.1"
characters:
dependency: transitive
description:
Expand Down Expand Up @@ -445,10 +445,10 @@ packages:
dependency: transitive
description:
name: file_selector_platform_interface
sha256: bf15ba6978161e4bb28beeb7cc8106d9d7febcfaf9f7daeab11ba5f54fa8148e
sha256: "2a7f4bbf7bd2f022ecea85bfb1754e87f7dd403a9abc17a84a4fa2ddfe2abc0a"
url: "https://pub.dev"
source: hosted
version: "2.5.0"
version: "2.5.1"
file_selector_web:
dependency: transitive
description:
Expand Down Expand Up @@ -514,10 +514,10 @@ packages:
dependency: "direct main"
description:
name: flutter_svg
sha256: "6ff8c902c8056af9736de2689f63f81c42e2d642b9f4c79dbf8790ae48b63012"
sha256: "8c5d68a82add3ca76d792f058b186a0599414f279f00ece4830b9b231b570338"
url: "https://pub.dev"
source: hosted
version: "2.0.6"
version: "2.0.7"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -700,10 +700,10 @@ packages:
dependency: transitive
description:
name: lints
sha256: "6b0206b0bf4f04961fc5438198ccb3a885685cd67d4d4a32cc20ad7f8adbe015"
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
version: "2.1.1"
local_notifier:
dependency: "direct main"
description:
Expand Down Expand Up @@ -732,10 +732,10 @@ packages:
dependency: "direct main"
description:
name: lottie
sha256: "23522951540d20a57a60202ed7022e6376bed206a4eee1c347a91f58bd57eb9f"
sha256: f461105d3a35887b27089abf9c292334478dd292f7b47ecdccb6ae5c37a22c80
url: "https://pub.dev"
source: hosted
version: "2.3.2"
version: "2.4.0"
marquee_widget:
dependency: "direct main"
description:
Expand Down Expand Up @@ -932,10 +932,10 @@ packages:
dependency: transitive
description:
name: path_provider_windows
sha256: d3f80b32e83ec208ac95253e0cd4d298e104fbc63cb29c5c69edaed43b0c69d6
sha256: "1cb68ba4cd3a795033de62ba1b7b4564dace301f952de6bfb3cd91b202b6ee96"
url: "https://pub.dev"
source: hosted
version: "2.1.6"
version: "2.1.7"
petitparser:
dependency: transitive
description:
Expand Down Expand Up @@ -1044,10 +1044,10 @@ packages:
dependency: "direct main"
description:
name: screen_capturer
sha256: a85d8da6f2737e762e251af2667c7c3aba6423fb221c28d1a8ae086b428b2a30
sha256: "5a1b6ec7f71cc928d62f1fb120ba1f08071ffe7f52f57f6b47ecfdfa05e133a9"
url: "https://pub.dev"
source: hosted
version: "0.1.4"
version: "0.1.5"
screen_retriever:
dependency: transitive
description:
Expand Down Expand Up @@ -1100,10 +1100,10 @@ packages:
dependency: transitive
description:
name: shared_preferences
sha256: "16d3fb6b3692ad244a695c0183fca18cf81fd4b821664394a781de42386bf022"
sha256: "396f85b8afc6865182610c0a2fc470853d56499f75f7499e2a73a9f0539d23d0"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
shared_preferences_android:
dependency: transitive
description:
Expand Down Expand Up @@ -1168,6 +1168,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.4"
shell_executor:
dependency: transitive
description:
name: shell_executor
sha256: f89eb17bb2660568a255bb5612f2773ba9295792d7bb6b96e3ef87985a9457fa
url: "https://pub.dev"
source: hosted
version: "0.1.4"
shortid:
dependency: transitive
description:
Expand Down Expand Up @@ -1369,10 +1377,10 @@ packages:
dependency: transitive
description:
name: url_launcher_platform_interface
sha256: "6c9ca697a5ae218ce56cece69d46128169a58aa8653c1b01d26fcd4aad8c4370"
sha256: bfdfa402f1f3298637d71ca8ecfe840b4696698213d5346e9d12d4ab647ee2ea
url: "https://pub.dev"
source: hosted
version: "2.1.2"
version: "2.1.3"
url_launcher_web:
dependency: transitive
description:
Expand Down Expand Up @@ -1409,26 +1417,26 @@ packages:
dependency: transitive
description:
name: vector_graphics
sha256: b96f10cbdfcbd03a65758633a43e7d04574438f059b1043104b5d61b23d38a4f
sha256: "670f6e07aca990b4a2bcdc08a784193c4ccdd1932620244c3a86bb72a0eac67f"
url: "https://pub.dev"
source: hosted
version: "1.1.6"
version: "1.1.7"
vector_graphics_codec:
dependency: transitive
description:
name: vector_graphics_codec
sha256: "57a8e6e24662a3bdfe3b3d61257db91768700c0b8f844e235877b56480f31c69"
sha256: "7451721781d967db9933b63f5733b1c4533022c0ba373a01bdd79d1a5457f69f"
url: "https://pub.dev"
source: hosted
version: "1.1.6"
version: "1.1.7"
vector_graphics_compiler:
dependency: transitive
description:
name: vector_graphics_compiler
sha256: "7430f5d834d0db4560d7b19863362cd892f1e52b43838553a3c5cdfc9ab28e5b"
sha256: "80a13c613c8bde758b1464a1755a7b3a8f2b6cec61fbf0f5a53c94c30f03ba2e"
url: "https://pub.dev"
source: hosted
version: "1.1.6"
version: "1.1.7"
vector_math:
dependency: transitive
description:
Expand Down Expand Up @@ -1497,10 +1505,10 @@ packages:
dependency: "direct main"
description:
name: walletconnect_flutter_v2
sha256: "84d8267827b353e1a9a2b3cb39ae28e405715b66c63a71e36d5bcb613883acdc"
sha256: "6b9ef246acdbc3684167d1519c73d7bb79fef68ae2c6fc822e350b4b5d3e8fd8"
url: "https://pub.dev"
source: hosted
version: "2.0.9"
version: "2.0.10"
watcher:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ dependencies:
open_filex: ^4.3.2
launch_at_startup: ^0.2.1
app_links: ^3.4.3
logging: ^1.1.1
logging: ^1.2.0
walletconnect_flutter_v2: ^2.0.9
preference_list: ^0.0.1
screen_capturer: ^0.1.2
Expand Down

0 comments on commit 8166496

Please sign in to comment.