flutter_logger_android_like 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 69

Android-like logger #

A simple logger that uses quite the same API as Android one.

Example #

import 'package:flutter_logger_android_like/flutter_logger_android_like.dart';

# global application configuration in main() for example
Future main() async {
  ...
  Log.initLogger(
      level: kReleaseMode ? Level.WARNING : Level.ALL,
      loggerName: 'MyLoggerName',
      logTagPrefix: 'MBZ_');

  Log.d(LogTag.API, 'Preparing to send a request to URL https://');
  Log.e(LogTag.BLUETOOTH, 'This is an error log example');
  Log.i('CustomTag', 'A message with a custom log tag');
  ...
}

will result in the following logs in the console

I/flutter (27453): INFO   : 2020-06-29 10:52:24.676206: Initializing logger MyLoggerName for DEBUG build with level ALL
I/flutter (27453): FINE   : 2020-06-29 10:52:24.686449: [MBZ_API]: Preparing to send a request to URL https://
I/flutter (27453): SEVERE : 2020-06-29 10:52:24.688176: [MBZ_BLUETOOTH]: This is an error log example
I/flutter (27453): INFO   : 2020-06-29 10:52:24.688403: [MBZ_CustomTag]: A message with a custom log tag

Versions #

1.0.0 #

  • Add basic logger similar to the one use for Android projects

1.0.1 #

  • Add custom tags when default LogTag enum is not enough

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import 'package:flutter_logger_android_like/flutter_logger_android_like.dart';

void main() {
  Log.initLogger(
      level: kReleaseMode ? Level.WARNING : Level.ALL,
      loggerName: 'MyLoggerName',
      logTagPrefix: 'MBZ_');

  Log.d(LogTag.API, 'Preparing to send a request to URL https://');
  Log.e(LogTag.BLUETOOTH, 'This is an error log example');
  Log.i('CustomTag', 'A message with a custom log tag');

  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Logger example'),
        ),
        body: Center(
          child: Text('Check console logs'),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_logger_android_like: ^1.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_logger_android_like/flutter_logger_android_like.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
43
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
86
Overall:
Weighted score of the above. [more]
69
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • flutter_logger_android_like that is a package requiring null.

Maintenance suggestions

The package description is too short. (-14 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
ansicolor ^1.0.2 1.0.2
flutter 0.0.0
logging ^0.11.4 0.11.4
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test