Simple Logger
// Singleton (factory)
final logger = SimpleLogger();
// Printed without called location
logger.info('Hello info!');
// -> 👻 INFO 2018-12-16 21:46:20.092695 [stacktrace disabled] Hello info!
// Printed function which returns object
logger.info(() => 'Hello info!');
// -> 👻 INFO 2018-12-16 21:46:20.092695 [stacktrace disabled] 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 [stacktrace disabled] Hello warning!
logger.shout('Hello shout!');
// -> 😡 SHOUT 2018-12-16 21:46:20.101308 [stacktrace disabled] Hello shout!
logger.setLevel(
Level.INFO,
// Enable printing called location, but this is expensive.
stacktraceEnabled: 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'
Please file feature requests and bugs at the issue tracker.
now
propertyexample/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 [stacktrace disabled] Hello info!
// Printed function which returns object
logger.info(() => 'Hello info!');
// -> 👻 INFO 2018-12-16 21:46:20.092695 [stacktrace disabled] 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 [stacktrace disabled] Hello warning!
logger.shout('Hello shout!');
// -> 😡 SHOUT 2018-12-16 21:46:20.101308 [stacktrace disabled] Hello shout!
logger.setLevel(
Level.INFO,
// Enable printing called location, but this is expensive.
stacktraceEnabled: 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'
}
Add this to your package's pubspec.yaml file:
dependencies:
simple_logger: ^0.3.0
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.
Now in your Dart code, you can use:
import 'package:simple_logger/simple_logger.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
0.7.4 | Dec 19, 2018 |
|
|
0.7.3 | Dec 17, 2018 |
|
|
0.7.2 | Dec 17, 2018 |
|
|
0.7.1 | Dec 17, 2018 |
|
|
0.7.0 | Dec 17, 2018 |
|
|
0.6.0 | Dec 17, 2018 |
|
|
0.5.0 | Dec 17, 2018 |
|
|
0.4.0 | Dec 17, 2018 |
|
|
0.3.0 | Dec 17, 2018 |
|
|
0.2.0 | Dec 17, 2018 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
69
|
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]
|
85
|
We analyzed this package on Feb 4, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter, web, other
No platform restriction found in primary library
package:simple_logger/simple_logger.dart
.
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.
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 |