1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-16 10:20:55 +01:00

Use Fimber for debug log instead of print()

This commit is contained in:
Triet Bui Minh 2019-10-13 10:01:29 +07:00 committed by Rongjian Zhang
parent 1b00a0ae69
commit 24aa8967ff
13 changed files with 39 additions and 29 deletions

View File

@ -17,6 +17,7 @@ import 'screens/login.dart';
import 'screens/issue.dart';
import 'screens/trending.dart';
import 'utils/utils.dart';
import 'package:fimber/fimber.dart';
class Home extends StatefulWidget {
@override
@ -122,7 +123,7 @@ class _HomeState extends State<Home> {
return MaterialApp(theme: themData, home: Scaffold(body: Text('a')));
}
// print(settings.activeLogin);
// Fimber.d(settings.activeLogin);
if (settings.activeAccount == null) {
return MaterialApp(theme: themData, home: LoginScreen());
}
@ -190,17 +191,20 @@ void main() async {
// try {
// String initialLink = await getInitialLink();
// print(initialLink);
// Fimber.d(initialLink);
// } on PlatformException {
// print('test');
// Fimber.d('test');
// }
// DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
// AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
// print('Running on ${androidInfo.model}'); // e.g. "Moto G (4)"
// Fimber.d('Running on ${androidInfo.model}'); // e.g. "Moto G (4)"
// IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
// print('Running on ${iosInfo.utsname.machine}'); // e.g. "iPod7,1"
// Fimber.d('Running on ${iosInfo.utsname.machine}'); // e.g. "iPod7,1"
// TODO: Later, should check to enable debug log in debug build only
Fimber.plantTree(DebugTree());
runApp(App());
}

View File

@ -1,6 +1,7 @@
import 'dart:io';
import 'dart:convert';
import 'dart:async';
import 'package:fimber/fimber.dart';
import 'package:http/http.dart' as http;
import 'package:uni_links/uni_links.dart';
import 'package:nanoid/nanoid.dart';
@ -122,7 +123,7 @@ class AuthModel with ChangeNotifier {
avatarUrl: info['avatar_url'] as String,
));
} catch (err) {
print(err);
Fimber.e('loginToGitlab failed', ex: err);
// TODO: show errors
} finally {
loading = false;
@ -133,7 +134,7 @@ class AuthModel with ChangeNotifier {
void init() async {
// Listen scheme
_sub = getUriLinksStream().listen(_onSchemeDetected, onError: (err) {
print(err);
Fimber.e('getUriLinksStream failed', ex: err);
});
var prefs = await SharedPreferences.getInstance();
@ -141,12 +142,12 @@ class AuthModel with ChangeNotifier {
// Read accounts
try {
String str = prefs.getString(StorageKeys.accounts);
print('read accounts: $str');
Fimber.d('read accounts: $str');
_accounts = (json.decode(str ?? '[]') as List)
.map((item) => Account.fromJson(item))
.toList();
} catch (err) {
print(err);
Fimber.e('prefs getAccount failed', ex: err);
_accounts = [];
}
@ -188,7 +189,7 @@ class AuthModel with ChangeNotifier {
body: json.encode({'query': query}))
.timeout(_timeoutDuration);
// print(res.body);
// Fimber.d(res.body);
final data = json.decode(res.body);
if (data['errors'] != null) {
@ -207,7 +208,7 @@ class AuthModel with ChangeNotifier {
final res = await http
.get(_apiPrefix + url, headers: headers)
.timeout(_timeoutDuration);
// print(res.body);
// Fimber.d(res.body);
final data = json.decode(res.body);
return data;
}

View File

@ -1,3 +1,4 @@
import 'package:fimber/fimber.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_highlight/theme_map.dart';
import 'package:git_touch/utils/utils.dart';
@ -35,7 +36,7 @@ class CodeModel with ChangeNotifier {
var vs = prefs.getInt(_kFontSize);
var vf = prefs.getString(_kFontFamily);
print('read code: $vh, $vs, $vf');
Fimber.d('read code: $vh, $vs, $vf');
if (themeMap.keys.contains(vh)) {
_theme = vh;
}
@ -53,7 +54,7 @@ class CodeModel with ChangeNotifier {
var prefs = await SharedPreferences.getInstance();
await prefs.setString(_kTheme, v);
print('write code theme: $v');
Fimber.d('write code theme: $v');
_theme = v;
notifyListeners();
@ -63,7 +64,7 @@ class CodeModel with ChangeNotifier {
var prefs = await SharedPreferences.getInstance();
await prefs.setInt(_kFontSize, v);
print('write code font size: $v');
Fimber.d('write code font size: $v');
_fontSize = v;
notifyListeners();
@ -73,7 +74,7 @@ class CodeModel with ChangeNotifier {
var prefs = await SharedPreferences.getInstance();
await prefs.setString(_kFontFamily, v);
print('write code font family: $v');
Fimber.d('write code font family: $v');
_fontFamily = v;
notifyListeners();

View File

@ -27,7 +27,7 @@ class NotificationPayload {
String numberStr = url.split('/').lastWhere((_) => true);
number = int.parse(numberStr);
} else {
// print(input);
// Fimber.d(input);
}
title = input['subject']['title'];

View File

@ -1,5 +1,6 @@
import 'dart:io';
import 'dart:async';
import 'package:fimber/fimber.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
@ -72,7 +73,7 @@ class ThemeModel with ChangeNotifier {
var prefs = await SharedPreferences.getInstance();
int v = prefs.getInt(storageKey);
print('read theme: $v');
Fimber.d('read theme: $v');
if (AppThemeType.values.contains(v)) {
_theme = v;
} else if (Platform.isIOS) {
@ -89,7 +90,7 @@ class ThemeModel with ChangeNotifier {
_theme = v;
await prefs.setInt(storageKey, v);
print('write theme: $v');
Fimber.d('write theme: $v');
notifyListeners();
}

View File

@ -64,7 +64,7 @@ class _ListStatefulScaffoldState<T, K>
}
void onScroll() {
// print(_controller.position.maxScrollExtent - _controller.offset);
// Fimber.d(_controller.position.maxScrollExtent - _controller.offset);
if (_controller.position.maxScrollExtent - _controller.offset < 100 &&
!_controller.position.outOfRange &&
!loading &&
@ -83,7 +83,7 @@ class _ListStatefulScaffoldState<T, K>
}
Future<void> _refresh({bool force = false}) async {
// print('list scaffold refresh');
// Fimber.d('list scaffold refresh');
setState(() {
error = '';
loading = true;
@ -110,7 +110,7 @@ class _ListStatefulScaffoldState<T, K>
}
Future<void> _loadMore() async {
// print('list scaffold load more');
// Fimber.d('list scaffold load more');
setState(() {
loadingMore = true;
});

View File

@ -65,7 +65,7 @@ class _LongListStatefulScaffoldState<T, K>
}
Future<void> _refresh() async {
// print('long list scaffold refresh');
// Fimber.d('long list scaffold refresh');
setState(() {
error = '';
loading = true;
@ -85,7 +85,7 @@ class _LongListStatefulScaffoldState<T, K>
}
Future<void> _loadMore() async {
// print('long list scaffold load more');
// Fimber.d('long list scaffold load more');
setState(() {
loadingMore = true;
});

View File

@ -1,5 +1,6 @@
import 'dart:io';
import 'package:fimber/fimber.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:git_touch/models/auth.dart';
@ -70,7 +71,7 @@ class _IssueFormScreenState extends State<IssueFormScreen> {
.showConfirm(context, Text('Issue created'));
Navigator.of(context).pop();
} catch (err) {
print(err); // TODO:
Fimber.e('postWithCredentials failed', ex: err); // TODO:
}
},
),

View File

@ -35,7 +35,7 @@ class NewsScreenState extends State<NewsScreen> {
final login = settings.activeAccount.login;
List data = await settings.getWithCredentials(
'/users/$login/received_events?page=$page&per_page=$pageSize');
// print(data.length);
// Fimber.d(data.length);
var hasMore = data.length == pageSize;
var events =
data.map<EventPayload>((item) => EventPayload.fromJson(item)).toList();

View File

@ -77,7 +77,7 @@ $key: pullRequest(number: ${item.number}) {
});
schema += '}';
// print(schema);
// Fimber.d(schema);
var data = await Provider.of<AuthModel>(context).query(schema);
_groupMap.forEach((repo, group) {
group.items.forEach((item) {
@ -90,7 +90,7 @@ $key: pullRequest(number: ${item.number}) {
}
});
});
// print(data);
// Fimber.d(data);
}
return _groupMap;

View File

@ -45,7 +45,7 @@ Color convertColor(String cssHex) {
Color getFontColorByBrightness(Color color) {
var grayscale = color.red * 0.3 + color.green * 0.59 + color.blue * 0.11;
// print('color: $color, $grayscale');
// Fimber.d('color: $color, $grayscale');
var showWhite = grayscale < 128;
return showWhite ? Colors.white : Colors.black;

View File

@ -1,3 +1,4 @@
import 'package:fimber/fimber.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:git_touch/models/notification.dart';
@ -61,7 +62,7 @@ class _NotificationItemState extends State<NotificationItem> {
case 'Commit':
return _buildIcon(Octicons.git_commit);
default:
print('Unhandled notification type: ${payload.type}');
Fimber.d('Unhandled notification type: ${payload.type}');
return _buildIcon(Octicons.octoface);
}
}

View File

@ -35,6 +35,7 @@ dependencies:
filesize: ^1.0.4
tuple: ^1.0.2
uri: ^0.11.3
fimber: ^0.3.2
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.