mirror of
https://github.com/jagandeepbrar/lunasea.git
synced 2026-08-31 12:42:34 +00:00
* [Packages] Added f_logs * [Logger] Initialized, captures crashes * [State, Logger] Safe-guarded setState, added logger tab in settings * [Logs] Implemented logs page, log types page, stub log view page * [Logs] Added log types page, log view page, stub log details page * [Logger] Finished details view * [Logger] Removed info logging * [Lidarr] Added logging to API calls * [Radarr] Added logging to API calls * [ListTiles] Added arrows for ListTiles that have more text * [Sonarr] Added logging to API calls * [Sonarr] Safetied some calculations * [SABnzbd] Added logging to API calls * [Sonarr] Prevent dividing by zero Closes #38
63 lines
2.0 KiB
Dart
63 lines
2.0 KiB
Dart
import 'dart:async';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:stack_trace/stack_trace.dart';
|
|
import 'package:f_logs/f_logs.dart';
|
|
|
|
class Logger {
|
|
Logger._();
|
|
|
|
static void initialize() {
|
|
LogsConfig config = FLog.getDefaultConfigurations()
|
|
..formatType = FormatType.FORMAT_SQUARE
|
|
..timestampFormat = 'MMMM dd, y - hh:mm:ss a';
|
|
FLog.applyConfigurations(config);
|
|
FlutterError.onError = (FlutterErrorDetails details) async {
|
|
bool inDebugMode = false;
|
|
assert(inDebugMode = true);
|
|
if (inDebugMode) {
|
|
FlutterError.dumpErrorToConsole(details);
|
|
}
|
|
Zone.current.handleUncaughtError(details.exception, details.stack);
|
|
};
|
|
}
|
|
|
|
static void warning(String className, String methodName, String text, {DataLogType type = DataLogType.DEFAULT}) {
|
|
FLog.warning(
|
|
className: className,
|
|
methodName: methodName,
|
|
text: text,
|
|
dataLogType: type.toString(),
|
|
);
|
|
}
|
|
|
|
static void error(String className, String methodName, String text, Object error, StackTrace trace, {DataLogType type = DataLogType.DEFAULT}) {
|
|
FLog.error(
|
|
className: className,
|
|
methodName: methodName,
|
|
text: text,
|
|
exception: Exception(error.toString()),
|
|
stacktrace: trace,
|
|
dataLogType: type.toString(),
|
|
);
|
|
}
|
|
|
|
static void fatal(Object error, StackTrace trace, {DataLogType type = DataLogType.DEFAULT}) {
|
|
FLog.fatal(
|
|
className: Trace.from(trace).frames[1].uri.toString() ?? 'Unknown',
|
|
methodName: Trace.from(trace).frames[1].member.toString() ?? 'Unknown',
|
|
text: error.toString(),
|
|
exception: Exception(error.toString()),
|
|
stacktrace: trace,
|
|
dataLogType: type.toString(),
|
|
);
|
|
}
|
|
|
|
static void exportLogs() {
|
|
FLog.exportLogs();
|
|
}
|
|
|
|
static void clearLogs() {
|
|
FLog.clearLogs();
|
|
}
|
|
}
|