Skip to content

Instantly share code, notes, and snippets.

View fredgrott's full-sized avatar
👾
focusing on flutter cross platform mobile dev

Fred Grott fredgrott

👾
focusing on flutter cross platform mobile dev
View GitHub Profile
@fredgrott
fredgrott / my_log_setup.dart
Created March 7, 2021 21:03
showing how to use fimber plugin
import 'package:fimber/fimber.dart';
import 'package:fimber_io/fimber_io.dart';
import 'package:flutter/widgets.dart';
import 'package:path_provider/path_provider.dart';
// setting tag for the whole app
FimberLog logger = FimberLog("flutter_log_fimber");
Fimber plantMeDebug() {
Fimber.plantTree(DebugTree.elapsed(useColors: true));
@fredgrott
fredgrott / my_main.dart
Created March 7, 2021 21:05
showing how to use fimber for logging
void main() async {
// timing and colors defined in function
plantMeDebug();
// ignore: no-empty-block
if (kIsWeb) {
// running on the web!
} else {
await plantFileTree();
@fredgrott
fredgrott / build_modes.dart
Last active March 11, 2021 11:04
build modes
// Copyright(c) 2021 Fredrick Allan Grott. All rights reserved.
// Use of this source code is governed by a BSD-style license.
import 'package:flutter/foundation.dart';
/// isInDebugMode is a function that provides a bool indicating whether in
/// the flutter build mode of debug or not.
/// @author Fredrick Allan Grott
bool get isInDebugMode {
bool _inDebugMode = false;
@fredgrott
fredgrott / main.dart
Created March 10, 2021 16:31
typical zone impl
// Copyright(c) 2021 Fredrick Allan Grott. All rights reserved.
// Use of this source code is governed by a BSD-style license.
import 'dart:async';
import 'dart:core';
import 'dart:developer';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app_exceptions/build_modes.dart';
@fredgrott
fredgrott / log_pens.dart
Created April 5, 2021 14:08
colorize logs
import 'package:ansicolor/ansicolor.dart';
final penFinest = AnsiPen()
..white(bold: true)
..rgb(r: 0, g: 0, b: 153, bg: true);
final penFiner = AnsiPen()
..black(bold: true)
..rgb(r: 255, g: 255, b: 255, bg: true);
@fredgrott
fredgrott / init_log.dart
Created April 5, 2021 14:22
logging init logic
import 'package:base_riverpod/app/utils/build_modes.dart';
import 'package:base_riverpod/app/utils/logging/log_pens.dart';
import 'package:logging/logging.dart';
import 'package:logging_appenders/logging_appenders.dart';
import 'package:simple_logger/simple_logger.dart';
final logger = SimpleLogger();
@fredgrott
fredgrott / types.dart
Created April 5, 2021 14:42
logger types
import 'package:logging/logging.dart';
abstract class LoggerType {
Logger get logger;
}
extension LoggerSpawner on LoggerType{
Logger newLogger(String name) => Logger('${logger.fullName}.$name');
@fredgrott
fredgrott / logger_types.dart
Created April 5, 2021 14:53
logger mixins
import 'package:base_riverpod/app/utils/logging/types.dart';
import 'package:logging/logging.dart';
// Works by setting the logger instance that we get in the class
// calling the mixin with a specific string name and thus allows
// a flexible setting what attributes of:
// error(cause)
// stackTrace
// level via logger suffix of finest, finer, fine, info, config,
// warning, severe, shout
import 'dart:async';
import 'dart:developer';
import 'package:base_riverpod/app/utils/logging/log_pens.dart';
/// To make sure that we collect all expected and unexpected exceptions we
@fredgrott
fredgrott / counter_notifier.dart
Created April 5, 2021 15:40
counter statenotifier
class CounterNotifier extends StateNotifier<CounterModel> with UtilityLogger {
CounterNotifier() : super(_initialValue);
static const _initialValue = CounterModel(0);
void increment() {
state = CounterModel(state.count + 1);
// log our state change
//myAppLog("count increased by 1");
logger.info(penInfo("count increased by 1"));