mydomain
No ADS
No ADS

FlutterArtist Log Viewer

  1. LogViewer
FlutterArtist LogViewer is a tool that allows users to review previously displayed application errors or warnings via SnackBar. This tool is beneficial for both end-users and developers.
The Logger system in FlutterArtist is more than just a logging tool; it acts as the application's "black box". Allowing end-users to access the LogViewer is a breakthrough step, significantly reducing communication time between support teams and users when issues arise. Instead of describing errors verbally, users can simply screenshot the LogViewer, complete with the full StackTrace and ErrorInfo.
  • FlutterArtist Rest Debug Viewer
  • FlutterArtist Debug Filter Model Viewer
  • FlutterArtist Debug Form Model Viewer
  • FlutterArtist Debug Filter Criteria Viewer
  • FlutterArtist Debug Storage Viewer (***)
  • FlutterArtist Code Flow Viewer

1. LogViewer

Once the application has at least one recorded Log entry, you can access this feature from the DebugMenu dropdown (typically located in the top-right corner of the application).
You can also open the LogViewer via code:
bool hasLogs = FlutterArtist.logger.hasLogEntries();

if(hasLogs) {
  await FlutterArtist.showLogViewerDialog();
}
No ADS
Note: By default, the Logger only stores up to 20 LogEntries; older LogEntries will be discarded. However, you can specify a different value using the FlutterArtist.config() method called in main.dart.
main.dart (*)
await FlutterArtist.config( 
  maxStoredLogEntryCount: 20, 
  ...
);
  • FlutterArtist config (***)
  • FlutterArtist Starter (***)
recentErrorCount
The number of errors occurring since the last time the Log Viewer was opened. This value will be reset to 0 immediately after the user closes the Log Viewer Dialog.
recentWarningCount
The number of warnings occurring since the last time the Log Viewer was opened. This value will be reset to 0 immediately after the user closes the Log Viewer Dialog.
totalErrorCount
The total number of error occurrences
totalWarningCount
The total number of warning occurrences.
Accessing Log Info via Code
void printLogInfo() {
  Logger logger = FlutterArtist.logger;

  print("hasRecentLogEntries: ${logger.hasRecentLogEntries}"); 
  print("recentErrorCount ${logger.recentErrorCount}"); 
  print("recentWarningCount ${logger.recentWarningCount}");
  print("totalErrorCount ${logger.totalErrorCount}");
  print("totalWarningCount ${logger.totalWarningCount}");

  for (LogEntry logEntry in logger.logEntries) {
    // error, warning,..
    print("logEntry.logEntryType: ${logEntry.logEntryType}");
    if (logEntry.logEntryType == LogEntryType.error) {
      ErrorInfo errorInfo = logEntry.errorInfo as ErrorInfo;
      print("errorInfo.errorMessage: ${errorInfo.errorMessage}");
      print("errorInfo.errorDetails: ${errorInfo.errorDetails}");
      print("StackTrace:\n ${errorInfo.stackTrace}");
    }
    //
    else if (logEntry.logEntryType == LogEntryType.warning) {
      WarningInfo warningInfo = logEntry.warningInfo as WarningInfo;
      print("warningInfo.errorMessage: ${warningInfo.warningMessage}");
    }
  }
}
DebugMenu is a built-in class in the flutter_artist library that allows you to create a button. When the user clicks this button, a dropdown menu will appear containing various standard FlutterArtist debugging functions. This article guides you on how to add this menu to your application.
No ADS
No ADS