Files
GitJournal/lib/screens/debug_screen.dart
Vishesh Handa ea733aacb5 Add a very simple Debug screen
This will show all the debug messages, which include when a file is
being ignored and not loaded, and hopefully all the exceptions. So the
user should be able to better understand why a file has been ignored.

It's not an ideal solution, but it's a quick fix.

Fixes #122
2020-05-06 01:09:57 +02:00

56 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:gitjournal/utils/logger.dart';
class DebugScreen extends StatefulWidget {
@override
_DebugScreenState createState() => _DebugScreenState();
}
class _DebugScreenState extends State<DebugScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(tr('settings.debug')),
leading: IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: () {
Navigator.of(context).pop();
},
),
),
body: ListView(
children: <Widget>[
for (var msg in Log.fetchLogs()) _buildLogWidget(msg),
],
),
);
}
Widget _buildLogWidget(LogMessage msg) {
var textStyle = Theme.of(context).textTheme.subhead;
textStyle = textStyle.copyWith(color: _colorForLevel(msg.l));
var str = DateTime.fromMillisecondsSinceEpoch(msg.t).toIso8601String() +
' ' +
msg.msg;
if (msg.ex != null) {
str += ' ' + msg.ex;
}
if (msg.stack != null) {
str += ' ' + msg.stack;
}
return Text(str, style: textStyle);
}
Color _colorForLevel(String l) {
switch (l) {
case 'e':
return Colors.red;
}
return Colors.black;
}
}