pretty_logging 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 72

pretty_logging

Pub

Standalone helper for colorful logging output, using pkg:io AnsiCode.

Installation #

In your pubspec.yaml:

dependencies:
  pretty_logging: 1.0.0

Usage #

Basic usage is very simple:

myLogger.onRecord.listen(prettyLog);

However, you can conditionally pass logic to omit printing an error, provide colors, or to provide a custom print function:

var pretty = prettyLog(
  logColorChooser: (_) => red,
  printFunction: stderr.writeln,
  omitError: (r) {
    var err = r.error;
    return err is AngelHttpException && err.statusCode != 500;
  },
);
myLogger.onRecord.listen(pretty);

1.0.0 #

  • Initial release.

example/main.dart

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

void main() {
  Logger.root
    ..level = Level.ALL
    ..onRecord.listen(prettyLog)
    ..info('Hey!')
    ..finest('Bye!')
    ..severe('Oops!', StateError('Wrong!'), StackTrace.current);
}

Use this package as a library

1. Depend on it

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


dependencies:
  pretty_logging: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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:pretty_logging/pretty_logging.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
44
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
72
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Primary library: package:pretty_logging/pretty_logging.dart with components: io.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
io ^0.3.2 0.3.3
logging ^0.11.0 0.11.3+2
Transitive dependencies
charcode 1.1.2
meta 1.1.7
path 1.6.4
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
Dev dependencies
pedantic ^1.0.0