Skip to content

Commit

Permalink
Add Fimber module, Log class
Browse files Browse the repository at this point in the history
  • Loading branch information
djkim committed Jul 31, 2019
1 parent eff62eb commit b453224
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/base/debug_utils.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:fimber/fimber.dart';
import 'package:flutter/foundation.dart';

class Log {
static initialize() {
if (!kReleaseMode) {
Fimber.plantTree(DebugTree());
}
}

static d(String tag, String message, {dynamic ex}) {
if (!kReleaseMode) {
Fimber.log("D", message, tag: tag, ex: ex);
}
}

static w(String tag, String message, {dynamic ex}) {
if (!kReleaseMode) {
Fimber.log("W", message, tag: tag, ex: ex);
}
}

static e(String tag, String message, {dynamic ex}) {
if (!kReleaseMode) {
Fimber.log("E", message, tag: tag, ex: ex);
}
}
}
4 changes: 4 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';

import 'base/debug_utils.dart';
import 'generated/i18n.dart';
import 'settings.dart';

Expand Down Expand Up @@ -36,6 +37,9 @@ class _MyHomePageState extends State<MyHomePage> {
if (_counter == null) {
return;
}

Log.d("main", "floating button pressed: counter = $_counter");

setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
Expand Down
5 changes: 5 additions & 0 deletions lib/myapp.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

import 'base/debug_utils.dart';
import 'generated/i18n.dart';
import 'main.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
// This widget is the root of your application.
MyApp() {
Log.initialize();
}

@override
Widget build(BuildContext context) {
return MaterialApp(
Expand Down
3 changes: 3 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ dependencies:
path:
synchronized:

# logging
fimber:

dev_dependencies:
flutter_test:
sdk: flutter
Expand Down

0 comments on commit b453224

Please sign in to comment.