err 0.7.2 copy "err: ^0.7.2" to clipboard
err: ^0.7.2 copied to clipboard

outdated

A logs router that can pop messages to the device screen. The routes are configurable for each log level.

Err #

pub package api doc

A logs router. The messages can be routed to:

  • Terminal
  • Flash messages
  • Snackbar messages

Configuration #

Configure the log levels's routes: available routes: console, screen, notifications or black hole. All the logs routed to the black hole will be silently swallowed: use it this to disable a route.

All routes default to console.

import 'package:err/err.dart';

var logger = ErrRouter(
   criticalRoute: [ErrRoute.console, ErrRoute.screen],
   errorRoute: [ErrRoute.screen, ErrRoute.console],
   warningRoute: [ErrRoute.screen, ErrRoute.console],
   infoRoute: [ErrRoute.screen],
   debugRoute: [ErrRoute.blackHole]);

Screen route #

Flash messages #

The flash messages are toast messages. They stay one second on the screen

@override
void initState() {
   logger.debugFlash("Init state");
    super.initState();
}

Available flash messages:

infoFlash(String msg): an information message

debugFlash(String msg): a debug message

warningFlash(String msg): a warning message

flash(String msg): alias for debugFlash

Screenshot

Snackbar messages #

The snackbar messages need a BuildContext

logger.infoScreen("File uploaded in $elapsed s", context: context);
logger.debugScreen("A debug message", context: context);
try {
   somethingWrong();
} catch(ex) {
   logger.criticalScreen(
      err: ex,
      msg: "Something wrong happened",
      context: context);  
}

Available messages

criticalScreen(String msg, {@required BuildContext context, dynamic err})

errorScreen(String msg, {@required BuildContext context, dynamic err})

warningScreen(String msg, {@required BuildContext context,dynamic err, bool short})

infoScreen(String msg, {@required BuildContext context,dynamic err, bool short})

debugScreen(String msg, {@required BuildContext context,dynamic err, bool short})

Parameters:

msg : a text message

err : an error or exception

short : if enabled the message will stay on screen for 5 seconds. If not it will stay until dismissed

context : the build context required for screen messages

Screenshot

Console route #

critical(String msg, {dynamic err})

error(String msg)

warning(String msg, {dynamic err})

info(String msg)

debug(String msg, {dynamic err})

Screenshot

By default the terminal output is configured for black and white. If your terminal supports colorized unicode emoticons use this parameter:

var logger = ErrRouter(
   // ...
   terminalColors: true);

Screenshot

Libraries used #

0
likes
0
pub points
45%
popularity

Publisher

unverified uploader

A logs router that can pop messages to the device screen. The routes are configurable for each log level.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

cupertino_icons, flushbar, flutter, fluttertoast

More

Packages that depend on err