Migrated pretty_logging to nndb

This commit is contained in:
thomashii 2021-03-10 00:40:38 +08:00
parent 2014c95105
commit 1db6b35fb3
2 changed files with 9 additions and 9 deletions

View file

@ -8,24 +8,24 @@ import 'package:io/ansi.dart';
/// ///
/// You can also pass a custom [printFunction] or [logColorChooser]. /// You can also pass a custom [printFunction] or [logColorChooser].
void prettyLog(LogRecord record, void prettyLog(LogRecord record,
{bool Function(LogRecord) omitError, {bool Function(LogRecord)? omitError,
void Function(String) printFunction, void Function(String)? printFunction,
AnsiCode Function(Level) logColorChooser}) { AnsiCode Function(Level)? logColorChooser}) {
logColorChooser ??= chooseLogColor; logColorChooser ??= chooseLogColor;
omitError ??= (_) => false; omitError ??= (_) => false;
printFunction ??= print; printFunction ??= print;
var code = logColorChooser(record.level); var code = logColorChooser(record.level);
if (record.error == null) printFunction(code.wrap(record.toString())); if (record.error == null) printFunction(code.wrap(record.toString())!);
if (record.error != null) { if (record.error != null) {
var err = record.error; var err = record.error;
if (omitError(record)) return; if (omitError(record)) return;
printFunction(code.wrap(record.toString() + '\n')); printFunction(code.wrap(record.toString() + '\n')!);
printFunction(code.wrap(err.toString())); printFunction(code.wrap(err.toString())!);
if (record.stackTrace != null) { if (record.stackTrace != null) {
printFunction(code.wrap(record.stackTrace.toString())); printFunction(code.wrap(record.stackTrace.toString())!);
} }
} }
} }

View file

@ -1,10 +1,10 @@
name: pretty_logging name: pretty_logging
version: 2.0.0 version: 2.1.0
description: Standalone helper for colorful logging output, using pkg:io AnsiCode. description: Standalone helper for colorful logging output, using pkg:io AnsiCode.
author: Tobe Osakwe <thosakwe@gmail.com> author: Tobe Osakwe <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/pretty_logging homepage: https://github.com/angel-dart/pretty_logging
environment: environment:
sdk: ">=2.10.0 <3.0.0" sdk: '>=2.12.0 <3.0.0'
dependencies: dependencies:
io: ^1.0.0 io: ^1.0.0
logging: ^1.0.0 logging: ^1.0.0