simple_logger 0.5.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 91

Simple Logger

Usage #

// Singleton (factory)
final logger = SimpleLogger();

// Printed without called location
logger.info('Hello info!');
// -> 👻 INFO  2018-12-16 21:46:20.092695 [caller info not available] Hello info!

// Printed function which returns object
logger.info(() => 'Hello info!');
// -> 👻 INFO  2018-12-16 21:46:20.092695 [caller info not available] Hello info!

logger.setLevel(Level.WARNING);

// Not printed
logger.info('Hello info!');

// Printed
logger.warning('Hello warning!');
// -> ⚠️ WARNING  2018-12-16 21:46:20.101114 [caller info not available] Hello warning!

logger.shout('Hello shout!');
// -> 😡 SHOUT  2018-12-16 21:46:20.101308 [caller info not available] Hello shout!

logger.setLevel(
  Level.INFO,
  // Includes  caller info, but this is expensive.
  includesCallerInfo: true,
);

// Printed with called location
logger.info('Hello info!');
// -> 👻 INFO  2018-12-16 21:50:03.562583 [example/simple_logger_example.dart 29:10 in main] Hello info!

// Customize level prefix
logger.levelSuffixes = {};
logger.info('Hello info!');
// -> INFO  2018-12-16 21:50:03.562583 [example/simple_logger_example.dart 29:10 in main] Hello info!

logger.formatter = (_log, info) => 'Customized output: (${info.message})';
logger.info('Hello info!');
// -> Customized output: (Hello info!)

logger.onLogged = (info) => print('Insert your logic with $info');
logger.info('Hello info!');
// -> Customized output: (Hello info!)
// -> Insert your logic with Instance of 'LogInfo'

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0.5.0 #

  • Rename to callerFrame from lineFrame
  • Change log to 'caller info not available' from 'stacktrace disabled' when includesCallerInfo is false

0.4.0 #

  • Rename to includesCallerInfo from stacktraceEnabled

0.2.0 #

  • Delete now property

0.1.1 #

  • First Release

example/simple_logger_example.dart

import 'package:simple_logger/simple_logger.dart';

// Singleton (factory)
final logger = SimpleLogger();

void main() {
  // Printed without called location
  logger.info('Hello info!');
  // -> 👻 INFO  2018-12-16 21:46:20.092695 [caller info not available] Hello info!

  // Printed function which returns object
  logger.info(() => 'Hello info!');
  // -> 👻 INFO  2018-12-16 21:46:20.092695 [caller info not available] Hello info!

  logger.setLevel(Level.WARNING);

  // Not printed
  logger.info('Hello info!');

  // Printed
  logger.warning('Hello warning!');
  // -> ⚠️ WARNING  2018-12-16 21:46:20.101114 [caller info not available] Hello warning!

  logger.shout('Hello shout!');
  // -> 😡 SHOUT  2018-12-16 21:46:20.101308 [caller info not available] Hello shout!

  logger.setLevel(
    Level.INFO,
    // Includes  caller info, but this is expensive.
    includesCallerInfo: true,
  );

  // Printed with called location
  logger.info('Hello info!');
  // -> 👻 INFO  2018-12-16 21:50:03.562583 [example/simple_logger_example.dart 29:10 in main] Hello info!

  // Customize level prefix
  logger.levelSuffixes = {};
  logger.info('Hello info!');
  // -> INFO  2018-12-16 21:50:03.562583 [example/simple_logger_example.dart 29:10 in main] Hello info!

  logger.formatter = (info) => 'Customized output: (${info.message})';
  logger.info('Hello info!');
  // -> Customized output: (Hello info!)

  logger.onLogged = (_log, info) => print('Insert your logic with $info');
  logger.info('Hello info!');
  // -> Customized output: (Hello info!)
  // -> Insert your logic with Instance of 'LogInfo'
}

Use this package as a library

1. Depend on it

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


dependencies:
  simple_logger: ^0.5.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:simple_logger/simple_logger.dart';
  
Version Uploaded Documentation Archive
1.4.1 Feb 27, 2019 Go to the documentation of simple_logger 1.4.1 Download simple_logger 1.4.1 archive
1.4.0 Feb 27, 2019 Go to the documentation of simple_logger 1.4.0 Download simple_logger 1.4.0 archive
1.3.1 Feb 27, 2019 Go to the documentation of simple_logger 1.3.1 Download simple_logger 1.3.1 archive
1.3.0 Feb 27, 2019 Go to the documentation of simple_logger 1.3.0 Download simple_logger 1.3.0 archive
1.2.1 Feb 27, 2019 Go to the documentation of simple_logger 1.2.1 Download simple_logger 1.2.1 archive
1.2.0 Feb 27, 2019 Go to the documentation of simple_logger 1.2.0 Download simple_logger 1.2.0 archive
1.1.1 Feb 27, 2019 Go to the documentation of simple_logger 1.1.1 Download simple_logger 1.1.1 archive
1.1.0 Feb 27, 2019 Go to the documentation of simple_logger 1.1.0 Download simple_logger 1.1.0 archive
1.0.0+1 Feb 26, 2019 Go to the documentation of simple_logger 1.0.0+1 Download simple_logger 1.0.0+1 archive
1.0.0 Feb 26, 2019 Go to the documentation of simple_logger 1.0.0 Download simple_logger 1.0.0 archive

All 37 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
83
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]
91
Learn more about scoring.

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

  • Dart: 2.3.0
  • pana: 0.12.15

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:simple_logger/simple_logger.dart.

Health issues and suggestions

Document public APIs. (-0.00 points)

28 out of 29 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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
logging ^0.11.3 0.11.3+2
stack_trace ^1.9.3 1.9.3
Transitive dependencies
path 1.6.2
Dev dependencies
test ^1.0.0