redux_logging 0.3.0

  • Installing
  • Versions
  • 92


Build Status codecov

Connects a Logger to a Redux Store. Can also simply print the latest state / action changes.

Logs every Action that is dispatched to the Store, along with the current State.

By default, this class does not print anything to your console or send data to a web service, such as Fabric or Sentry. It simply logs entries to a Logger instance.

If you simply want to print the latest action and state to your console / terminal, create a new LoggingMiddleware.printer() and pass it to your Store upon creation.

If you want more control over where the logged data is sent, you can listen to your Logger's onRecord Stream.

Dart Versions

  • Dart 1 support: 0.1.x
  • Dart 2 Support: 0.2.x+

Simple Printing example

If you just want an easy way to print actions to your console / terminal as they are dispatched, use the new LoggingMiddleware.printer() factory.

import "package:redux/redux.dart";
import 'package:redux_logging/redux_logging.dart';

final store = new Store<int>(
  (int state, dynamic action) => state + 1,
  initialValue: 0,
  middleware: [new LoggingMiddleware.printer()]

store.dispatch("Hi"); // prints {Action: "Hi", Store: 1, Timestamp: ...}


If you only want to log actions to a Logger, and choose how to handle the output, use the default constructor.

import 'package:logging/logging.dart';
import "package:redux/redux.dart";
import 'package:redux_logging/redux_logging.dart';

// Create your own Logger
final logger = new Logger("Redux Logger");

// Pass it to your Middleware
final middleware = new LoggingMiddleware(logger: logger);
final store = new Store<int>(
  (int state, dynamic action) => state + 1,
  initialState: 0,
  middleware: [middleware],

// Note: One quirk about listening to a logger instance is that you're
// actually listening to the Singleton instance of *all* loggers.
  // Filter down to [LogRecord]s sent to your logger instance
  .where((record) => record.loggerName ==
  // Print them out (or do something more interesting!)
  .listen((loggingMiddlewareRecord) => print(loggingMiddlewareRecord));

Formatting the log message

This library includes two formatters out of the box:

  • LoggingMiddleware.singleLineFormatter
  • LoggingMiddleware.multiLineFormatter

You can optionally control the format of the message that will be logged by implementing your own MessageFormatter and passing it to the LoggingMiddleware constructor. It is a simple function that takes three parameters: the State, Action, and Timestamp.

Formatting Example

import "package:redux/redux.dart";
import 'package:redux_logging/redux_logging.dart';

// Create a formatter that only prints out the dispatched action
String onlyLogActionFormatter<State>(
  State state,
  dynamic action,
  DateTime timestamp,
) {
  return "{Action: $action}";

// Create your middleware using the formatter.
final middleware = new LoggingMiddleware(formatter: onlyLogActionFormatter);

// Add the middleware with your formatter to your Store
final store = new Store<int>(
  (int state, dynamic action) => state + 1,
  initialState: 0,
  middleware: [middleware],



  • Bump to Redux 3.0.0
  • Fix Dart 2 bug


  • Dart 2 support


  • Fix formatter for printer


  • Move to Github


  • Fix examples


  • Include description in pubspec.yaml


  • Initial version, a LoggingMiddleware for Redux, which connects the dispatched actions to to a Logger.
  • Includes a printer factory, which prints all logged messages to the your console / terminal.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  redux_logging: ^0.3.0

2. Install it

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.

3. Import it

Now in your Dart code, you can use:

import 'package:redux_logging/redux_logging.dart';
Version Uploaded Documentation Archive
0.3.0 Mar 30, 2018 Go to the documentation of redux_logging 0.3.0 Download redux_logging 0.3.0 archive
0.2.0 Mar 20, 2018 Go to the documentation of redux_logging 0.2.0 Download redux_logging 0.2.0 archive
0.1.4 Nov 26, 2017 Go to the documentation of redux_logging 0.1.4 Download redux_logging 0.1.4 archive
0.1.3 Nov 25, 2017 Go to the documentation of redux_logging 0.1.3 Download redux_logging 0.1.3 archive
0.1.2 Sep 7, 2017 Go to the documentation of redux_logging 0.1.2 Download redux_logging 0.1.2 archive
0.1.1 Aug 27, 2017 Go to the documentation of redux_logging 0.1.1 Download redux_logging 0.1.1 archive
0.1.0 Aug 27, 2017 Go to the documentation of redux_logging 0.1.0 Download redux_logging 0.1.0 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:redux_logging/redux_logging.dart.

Maintenance suggestions

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use redux_logging.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
logging >=0.11.3 <0.12.0 0.11.3+2
redux >=3.0.0 <4.0.0 3.0.0
Dev dependencies
test >=0.12.32+2 <0.13.0