Sandbox Logger

A simple tool for beautiful and colorful console prints.


  • Log in multiple colors
  • Log texts
  • Log Maps
  • Log Error's/stacktrace.
  • Log Objects
  • Determine logs max horizontal lenght

Getting started

In the pubspec.yaml of your flutter project, add the following dependency:


Import it:

import 'package:sandbox_logger/sandbox_logger.dart';

Use it:

// Call the log function
SandLog.text('Hello world');

Concatenate log types and easily get a nice log at the end

The models to be loged

class Person {
  final String name; final int age; final bool isAProgrammer;
  const Person(, this.age, this.isAProgrammer);

  // Needs to have a toString like this:
  String toString() => 'Person(name: $name, age: $age, isAProgrammer: $isAProgrammer)';
final map1 = {'name': 'Igor', 'age': 22};
final map2 = {'name': 'Daniel', 'age': 38};
final StackTrace stackTrace = StackTrace.fromString(fakeStackText);

Using the log building types to build the final log

// Building a log:
    .text('This is a header text')
    .error('FormatException: Invalid double', stackTrace)
    .map( map1 )
    .listOfMap( [ map1 , map2 ] )
    .object( Person('Igor', 22, true) )
    .listOfObject( [ Person('Igor', 22, true) , Person('Daniel', 38, true) ] );

Implementation of logs:

Text log:

SandLog.text('This is a test text\nLets see the result');

Map log:

final map = {'name': 'Igor', 'age': 22};;

List of map log:

final map1 = {'name': 'Igor', 'age': 22};
final map2 = {'name': 'Daniel', 'age': 38};
SandLog.listOfMap([map1, map2]);

Stacktrace logs:

try {
  double.parse('text impossible to parse');
} catch (error, stackTrace) {
  SandLog.error(error, stackTrace);

Terminal output:

Logging object and list of object:

A object that has a .toString() with this pattern:

class Person {
  final String name;
  final int age;
  final bool isAProgrammer;
  const Person(, this.age, this.isAProgrammer);

  // Needs to be a toString like this:
  String toString() => 'Person(name: $name, age: $age, isAProgrammer: $isAProgrammer)';

That pattern of the "toString()" above can be casted to a map that will be logged

final person1 = Person('Igor', 22, true);
final person2 = Person('Daniel', 38, true);

SandLog.object(person1); // Log 1 object

SandLog.listOfObject([person1, person2]); // Log a list of object

Terminal output:


Using configurations for a specific log:

This setting will only apply to this log. It is not a global/default setting as we will see below

  .text('Test of color & max horizontal lenght setters')
  .setColorTo( // Choose the desired color
  .setMaxLength(30); // Set the max horizontal lenght

Setting default configurations:

This configuration will be used in all the logs as default values. Recomended to set this in the main function of the project

// This configuration will be valid to all logs
  defaultMaxHorizontalLenght: 40,
  defaultColor: LogColor.yellow,
  defaultErrorColor: LogColor.magenta,

Another possible setting is to change the border style:

final LogBorderSytle myCustomBorderStyle = LogBorderSytle(
  topRightBorder: '╗',
  topLeftBorder: '╔',
  traceBorder: '═',
  middleRightBorder: '╠',
  middleLeftBorder: '╣',
  connectorLeftBorder: '╠',
  connectorRightBorder: '╣',
  bottomRightBorder: '╝',
  bottomLeftBorder: '╚',

  defaultBorderStyle: myCustomBorderStyle,

Important! Configure when to make logs

The most important configuration is having a way to enable or disable the logs. For exemple: in a release apk that final users will use, you don't want logs to be printed.

  // Will only print when running debug mode, nothing will be logged in release
  isLogActivated: kDebugMode, // Will only print is boolean is true, 

Other functionalities

You can make a plain text log with any of the log colors These logs will not have any type of formatting.

logInBlack('Black text');
logInBlue('Blue text');
logInCyan('Cyan text');
logInGreen('Green text');
logInMagenta('Magenta text');
logInRed('Red text');
logInWhite('White text');
logInYellow('Yellow text');

Made with ❤ by
if you like the package, give a 👍