journal 0.3.0 journal: ^0.3.0 copied to clipboard
A simple log writer and subscriber usable both from libraries and applications.
Journal #
A simple log writer and subscriber usable both from libraries and applications.
Example #
To create a journal, simply instantiate Journal
with a unique name, normally the name of the
package that emits the entries.
import 'package:journal/journal.dart';
const journal = Journal('http_server');
Following that, you can simply log entries.
journal.info('Started HTTP server.', values: {'port': port.toJournal});
if (address.isUnbound) {
journal.warn('Be careful when not binding the server to a concrete address.');
}
Default output #
The default output uses a pretty-printed format on all supported platforms.
Note that you might need to set Journal.forceFormatTerminalOutput
to get properly formatted
output in your terminal.
Default output in Windows Terminal
Default output in Mozilla Firefox
Default output in Google Chrome
Configuration #
To configure journal
, you can either implement your own JournalOutput
or override the parameters
of the default one.
Journal.outputs = const [
DefaultJournalOutput(
displayTimestamp: true,
displayLevel: true,
displayZone: false,
displayName: true,
displayTrace: true,
),
];
Compatibility #
For compatibility with the logging
package, simply direct its records to journal
.
import 'package:logging/logging.dart'
Logger.root.onRecord.listen((record) {
Journal.record(
record.loggerName,
JournalEntry.fromLogging(record),
);
});
Release history #
See the changelog for a detailed list of changes throughout the package's history.