super_logging 0.2.0

Super Logging #

The usual dart logging module with superpowers!

Sponsor

pub package

This will log to

  • stdout
  • disk
  • sentry.io

How do I use this? #

import 'package:super_logging/super_logging.dart';  // you only need this import for initialize
import 'package:logging/logging.dart';  // this is the regular dart module

final _logger = Logger("main");

main() async {
  // you must initalize before using the logger!
  await SuperLogging.init();
  
  _logger.info("hello!");
}

This will log to stdout by default. Use may also choose to :-

Use sentry.io #

This module can upload errors to sentry.io if you want.

(Errors can be logged by passing errors like so: _logger.fine(msg, e, trace);)

await SuperLogging.init(
  // Passing this will enable sentry uploads.
  sentryDsn: "YOUR_SENTRY_DSN",

  // [optional] Has auto retry of uploads built right in!
  sentryAutoRetryDelay: Duration(seconds: 5),
  
  // [optional] Get current user info, which will be sent to sentry.
  // This appears in their web gui.
  getCurrentUser: (deviceInfo) {
    return User(
      username: "john",
      extras: deviceInfo,  // contains valuable info like device manufacturer, model etc.
    )
  },
  
  // [optional] automatically turn off sentry/file logging during debug mode.
  bool considerDebugMode: true,
)

Use the disk #

await SuperLogging.init(
  // Passing this will enable logging to the disk.
  // New log files are created every day.
  String logFileDir: "LOGGING_DIRECORY",

  // This controls the max no of log files inside [logFileDir].
  // This prevents log files blowing up.
  // Older log files are deleted automatically.
  int maxLogFiles: 10,
)

Can I log uncaught errors? #

Yes!

If you pass a function to the run argument, super logging will register hooks for FlutterError.onError and use runZoned() to catch un-caught errors.

import 'package:super_logging/super_logging.dart';
import 'package:logging/logging.dart';

final _logger = Logger("main");

main() async {
  await SuperLogging.init(
    run: () {
      runApp(Main());  // `Main` is the root widget
    }
  );
}

This is disabled if the app is running in debug mode, and considerDebugMode is set to true

Use this package as a library

1. Depend on it

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


dependencies:
  super_logging: ^0.2.0

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:super_logging/super_logging.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
59
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
57
Overall:
Weighted score of the above. [more]
71
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

11 out of 11 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance issues and suggestions

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

The package description is too short. (-13 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.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and super_logging.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
device_info ^0.4.0+1 0.4.0+2
flutter 0.0.0
intl ^0.15.8 0.15.8
logging ^0.11.3+2 0.11.3+2
package_info ^0.4.0+1 0.4.0+5
path ^1.6.2 1.6.2
sentry ^2.2.0 2.2.0
Transitive dependencies
async 2.3.0
charcode 1.1.2
collection 1.14.11
http 0.12.0+2
http_parser 3.1.3
meta 1.1.6 1.1.7
pedantic 1.8.0+1
sky_engine 0.0.99
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
usage 3.4.1
vector_math 2.0.8
Dev dependencies
flutter_test

Admin