logging_appenders 0.2.2
logging_appenders #
Native dart package for logging appenders usable with the logging package.
It currently includes appenders for:
- Local Logging
print()
PrintAppender- Rolling File Appender. RotatingFileAppender
- Remote Logging
Performance of Remote Logging Appenders #
I am not sure if it is wise to use this in production, but it's great during beta testing with a handful of users so you have all logs available.
It tries to stay reasonable performant by batching log entries and sending them off only every few seconds. If network is down it will retry later. (with an ever increasing interval).
Getting Started #
After installing package logging
and logging_appenders
:
import 'package:logging/logging.dart';
import 'package:logging_appenders/logging_appenders.dart';
final _logger = Logger('main');
void main() {
Logger.root.level = Level.ALL;
PrintAppender()..attachToLogger(Logger.root);
_logger.fine('Lorem ipsum');
}
Outputs:
$ dart main.dart
2019-08-19 15:36:03.827563 FINE main - Lorem ipsum
Color Formatter #
PrintAppender(formatter: const ColorFormatter())
..attachToLogger(Logger.root);
Produces:
0.2.2 #
- Added a
ColorFormatter
when outputting to interactive terminal.- If
stdout.supportsAnsiEscapes
returns true, thePrintAppender
will default toColorFormatter
- If
- Correctly dispose close timer.
0.2.1+1 #
- Make
LogzIoApiAppender
more configurable (host, type, bufferSize, etc.). - Make internal logging levels configurable, to help debugging the Appenders themselves.
0.2.1 #
- Improved API, use
attachToLogger
. - Updated documentation, improved readme
- More test coverage for
RotatingFileAppender
[0.2.0] - 2019-08-19
- Renamed everything from
handler
toappender
. - Major refactoring.
[0.1.0+2] - 2019-04-20 hotfix
[0.1.0+1] - 2019-04-20 broaden dependencies for 0.x versions.
[0.1.0] - 2019-04-20 initial release
- Initial release with logz.io and loki logging backends.
import 'package:logging/logging.dart';
import 'package:logging_appenders/logging_appenders.dart';
final _logger = Logger('example');
void main() {
Logger.root.level = Level.ALL;
final appender = PrintAppender(formatter: const ColorFormatter())
..attachToLogger(Logger.root);
_logger.fine('Lorem ipsum');
_logger.info('An important info message');
_logger.severe('This is bad.');
_logger.shout('This is just impolite');
// optionally dispose of the appender.
appender.dispose();
}
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
logging_appenders: ^0.2.2
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:logging_appenders/logging_appenders.dart';
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
72
|
Health:
Code health derived from static analysis.
[more]
|
100
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
90
|
Overall:
Weighted score of the above.
[more]
|
84
|
We analyzed this package on Dec 7, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.6.1
- pana: 0.12.21
Platforms
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
Health suggestions
Fix lib/src/rotating_file_appender.dart
. (-0.50 points)
Analysis of lib/src/rotating_file_appender.dart
reported 1 hint:
line 59 col 10: Close instances of dart.core.Sink
.
Maintenance issues and suggestions
Support latest dependencies. (-10 points)
The version constraint in pubspec.yaml
does not support the latest published versions for 1 dependency (dio
).
Dependencies
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.1.0 <3.0.0 | ||
clock | >=1.0.0 <2.0.0 | 1.0.1 | |
dio | >=2.1.0 <3.0.0 | 2.2.2 | 3.0.7 |
intl | >=0.15.0 <1.0.0 | 0.16.0 | |
io | >=0.3.0 <1.0.0 | 0.3.3 | |
logging | >=0.11.3+2 <1.0.0 | 0.11.3+2 | |
meta | >=1.0.0 <2.0.0 | 1.1.8 | |
rxdart | >=0.20.0 <1.0.0 | 0.22.6 | 0.23.0-dev.2 |
Transitive dependencies | |||
charcode | 1.1.2 | ||
cookie_jar | 1.0.1 | ||
source_span | 1.5.5 | ||
string_scanner | 1.0.5 | ||
term_glyph | 1.1.0 | ||
Dev dependencies | |||
fake_async | ^1.0.1 | ||
mockito | ^4.1.0 | ||
path | >=1.6.0 <2.0.0 | 1.6.4 | |
pedantic | >=1.5.0 <2.0.0 | ||
test | >=1.5.0 <2.0.0 |