Tiny Dart logging package

Overview

Bonsai

Features

A tiny Dart logging package.

Based loosely on "Android style" debug logging and somewhat influenced by Square's logcat

Uses the logging functionality from the dart:developer package.

Getting started

Just import the package and call the init method somewhere, like at the start of your main():

import 'package:bonsai/bonsai.dart';

void main() {
  const debug = true;
  if (debug) {
    Log.init();
  }
  //...
}

Usage

Bonsai adds a static extension method onto Object to make basic usage very simple:

class MyClass {
  void doSomething() {
    log("hello I'm doing something");
  }
}

Of course more custom usage is also available:

 Log.d('Main', 'custom tags are also available as it sending custom data:', data: myObj);

  // there is also a specific method for errors:
  try {
    throw UnsupportedError('soemthing went wrong');
  } catch (e, st) {
    Log.e('some error happened', e, st);
  }

In Flutter apps, the logging will be sent to usual app console output. However if you are using this for a Dart command line application or want output when running unit tests for Flutter apps, you'll likely want to enable output to stderr:

 // pass true to enable output to stderr
 Log.init(true);

Example stdout/stderr commandline output looks like:

FINE: 2021-10-01 16:29:54.573106: [MyClass] hello I'm doing something
FINE: 2021-10-01 16:29:54.576928: [Main] custom tags are also available
SEVERE: 2021-10-01 16:29:54.577526: some error happened
FormatException: something went very wrong
#0      main (file:///home/maks/work/bonsai_dart/example/bonsai_example.dart:16:5)
#1      _delayEntrypointInvocation.
   
     (dart:isolate-patch/isolate_patch.dart:297:19)
#2      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

   

The name?

Following in the great heritage of naming Logging packages in Android: logging, trees, tiny logging package... :-)

You might also like...

This package allows programmers to annotate Dart objects in order to Serialize / Deserialize them to / from JSON

This package allows programmers to annotate Dart objects in order to Serialize / Deserialize them to / from JSON. Why? Compatible with all target plat

Jan 6, 2023

A dart package for decode and encode emv QR code

A dart package for decode and encode emv QR code

Nov 15, 2022

Dart package for random strings and numbers, with weights

randomness Dart package for random strings and numbers, with weights Random strings, numbers. RNG with weights. Cryptographically secure options. Gett

Aug 6, 2022

Dart wrapper via dart:ffi for https://github.com/libusb/libusb

libusb Dart wrapper via dart:ffi for https://github.com/libusb/libusb Environment Windows(10) macOS Linux(Ubuntu 18.04 LTS) Usage Checkout example Fea

Dec 20, 2022

Extensible Dart interpreter for Dart with full interop

dart_eval is an extensible interpreter for the Dart language, written in Dart. It's powered under the hood by the Dart analyzer, so it achieves 100% c

Dec 28, 2022

Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.

Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.

Jan 2, 2023

A package that helps with encoding and decoding of geohashes.

A package that helps with encoding and decoding of geohashes.

georange Georange is a package that helps with encoding geohashes, decoding geohashes,calculating distance between 2 points and generating latitudinal

Feb 17, 2022

This package wraps Airtime, Sms, and Voice call from Africa's Talking APIs.

This package wraps some functionalities from Africa's Talking API The functionalities implemented are; Sms send message fetch messages generate checko

May 31, 2022
Releases(v1.0.1)
Owner
Maksim Lin
Android Developer, Flutter Developer & GDE
Maksim Lin
null 2 Apr 17, 2022
A Dart build script that downloads the Protobuf compiler and Dart plugin to streamline .proto to .dart compilation.

A Dart build script that downloads the Protobuf compiler and Dart plugin to streamline .proto to .dart compilation.

Julien Scholz 10 Oct 26, 2022
A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully & easily modifiable.

A package that lets you include a cool, nice looking and validated Password TextFormField in your app to enhance user experience. The package is fully

Muhammad Hamza 20 Jun 7, 2022
A Dart package to web scraping data from websites easily and faster using less code lines.

Chaleno A flutter package to webscraping data from websites This package contains a set of high-level functions that make it easy to webscrap websites

António Nicolau 30 Dec 29, 2022
A pure dart package to apply useful rate limiting strategies on regular functions.

Rate limiting is a strategy for limiting an action. It puts a cap on how often someone can repeat an action within a certain timeframe. Using rate_limiter we made it easier than ever to apply these strategies on regular dart functions.

Stream 24 Dec 14, 2022
This package binds to Cronet's native API to expose them in Dart.

Experimental Cronet Dart bindings This package binds to Cronet's native API to expose them in Dart. This is an HTTP Client Package with almost the sam

Google 103 Dec 9, 2022
The Dart code generator for your package versions. 🎯

The Dart code generator for your package versions. There is no way to get the package version from the code in the Dart ecosystem. Installation Add bu

Daichi Furiya 12 Dec 14, 2022
Flutter_socks_proxy is a dart package, HTTP/Socks4/Socks5 proxy

flutter_socks_proxy flutter_socks_proxy is a dart package, HTTP/Socks4/Socks5 proxy Usage Use global import 'dart:convert';

null 12 Oct 23, 2022
Pub Release is a package to assist in publishing dart/flutter packages to pub.dev.

description Pub Release is a package that automates publishing dart/flutter packages to pub.dev. README Pub Release is a package that automates publis

Noojee I.T. Pty Ltd 16 Oct 13, 2022
A dart package to help you parse and evaluate infix mathematical expressions into their prefix and postfix notations.

A dart package to help you parse and evaluate infix mathematical expressions into their prefix and postfix notations.

Miguel Manjarres 2 Jan 28, 2022