Skip to content

Commit

Permalink
feat: view native log in logs page
Browse files Browse the repository at this point in the history
  • Loading branch information
Yesterday17 committed Aug 23, 2024
1 parent 9b18d56 commit b973f7a
Show file tree
Hide file tree
Showing 8 changed files with 546 additions and 178 deletions.
48 changes: 48 additions & 0 deletions lib/native/api/logging.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,53 @@
import '../frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';

// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `fmt`

void initLogger({required String path}) =>
RustLib.instance.api.crateApiLoggingInitLogger(path: path);

Future<List<LogEntry>> readLogs({required String path}) =>
RustLib.instance.api.crateApiLoggingReadLogs(path: path);

class LogEntry {
final String time;
final String level;
final String? module;
final String? file;
final int? line;
final String message;
final String structured;

const LogEntry({
required this.time,
required this.level,
this.module,
this.file,
this.line,
required this.message,
required this.structured,
});

@override
int get hashCode =>
time.hashCode ^
level.hashCode ^
module.hashCode ^
file.hashCode ^
line.hashCode ^
message.hashCode ^
structured.hashCode;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LogEntry &&
runtimeType == other.runtimeType &&
time == other.time &&
level == other.level &&
module == other.module &&
file == other.file &&
line == other.line &&
message == other.message &&
structured == other.structured;
}
Loading

0 comments on commit b973f7a

Please sign in to comment.