Flutter app world logo
  • Home
  • Flutter App
    • UI
    • ads
    • Timeline
    • Widgets
    • Plugin
    • Games
    • library
    • Templates
    • Maps
    • Timeline
    • clock
    • Animation
    • packages
  • Dart
  • Marketplace

Tiny Dart logging package

 October 4, 2021   Login, packages, Packages

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.<anonymous closure> (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… 🙂

Contribute to logging package on GitHub

https://github.com/maks/bonsai_dart
Flutterappworld
Flutterappworld

Provides the list of the opensource Flutter apps collection with GitHub repository.

<< Facebook UI Clone using Flutter An application that can display weather based on GPS position >>

Flutter App Templates

Flutter App Template

Subscribe

Loading

Recent Posts

  • Flutter Client SDK for LiveKit
  • PrepPDF app provides organised access to previous year question papers and solutions
  • The project is a Flutter library for SMS verification codes
  • OpSo – Open Source Programs App
  • Learning app for kids

Categories

  • 3D
  • Admin
  • ads
  • AI
  • Alert
  • Algorithm
  • Analytics
  • Animation
  • Ant
  • API
  • Article
  • Audio
  • Authentication
  • Avatar
  • Backend
  • Badges
  • Bank
  • Barcode
  • Binding
  • Bitcoin Ticker
  • Bitwarden
  • BLoC
  • Blockchain
  • Bluetooth
  • Blur
  • BMI
  • Book
  • Booking
  • Button
  • Cache
  • calculator
  • Calendar
  • Camera
  • canvas
  • Captcha
  • Carousel
  • Carousel
  • Cart
  • Chart
  • chat
  • Chips
  • Choice
  • Class
  • Clipboard
  • Clipper
  • clock
  • Collection
  • Colors
  • Command Line
  • Community
  • Contact
  • Converter
  • Country Code
  • Covid-19
  • Crypto Currency
  • Cupertino
  • Currency
  • Dart
  • Dashboard
  • Database
  • Date & Time
  • Designs
  • Desktop
  • Desktop App
  • Dev Tool
  • Dialog
  • Doctor App
  • Downloader
  • Draw
  • Drawer
  • Dropdown
  • E-Learning
  • ecommerce
  • Editor
  • Education
  • Effect
  • Emoji
  • Encryption
  • Event
  • Exercises
  • Extension
  • Face Detection
  • Facebook
  • Feeds
  • Figma
  • File Manager
  • Files
  • Firebase
  • Flight
  • Floating
  • Flutter App
  • Flutter Card
  • Flutter Desktop
  • Food Ordering
  • Form
  • Framework
  • Furniture
  • Furniture Store
  • Games
  • Generator
  • Geocoding
  • Google Sheets
  • Graphics
  • GraphQL
  • Gravatar
  • grid
  • Grocery
  • Header
  • Health
  • Hooks
  • Http
  • Icons
  • Img
  • Input
  • IoT
  • Javascript
  • Json
  • Keyboard
  • Language Learning
  • Launcher
  • Laundry
  • Layout
  • Library
  • library
  • List
  • ListTile
  • Loader
  • Location
  • Login
  • Machine Learning
  • Mail
  • Maps
  • Marketplace
  • Material Design
  • Media
  • Medical
  • Menu
  • Messenger App
  • Meta Layer
  • Mobx
  • Movie
  • Music Player
  • MVC
  • Navigation
  • Navigation bar
  • Network
  • Neumorphic
  • News
  • Notes App
  • NuBank
  • on-boarding
  • OnBoarding
  • OTP
  • packages
  • Packages
  • Padding
  • Paginating
  • PAGINATION
  • parallax
  • Parser
  • Password
  • Payment Gateway
  • PDF
  • Picker
  • Pie chart
  • Pin Code
  • Pizza
  • Plugin
  • plugin
  • Podcast
  • popup
  • portfolio
  • POS
  • Progress
  • Push Notification
  • QR Code
  • Quiz
  • Radio Component
  • Rating Bar
  • Redux
  • Refresh
  • Remote
  • Render
  • Responsive
  • Rest API
  • Restaurants
  • Ribbon
  • Routing
  • School App
  • Screen
  • Scroll
  • Search
  • Shopping
  • Sidebar
  • Sign in
  • Simulator
  • Skeleton
  • Slider
  • SMS
  • Social Media
  • Solar
  • Splash screens
  • State Management
  • Stickers
  • Stocks Market
  • Streaming
  • SVG
  • Swagger
  • Swipe
  • Switch
  • TabBar
  • Table
  • Tags
  • Task Manager
  • Taxi
  • Templates
  • Testing
  • Text
  • Text Field
  • Theme
  • TikTok
  • Time Tracking
  • Timeline
  • Timelines
  • Toast
  • Todo
  • Toggle
  • Tools
  • Transition
  • Translator
  • Transport
  • Travel
  • TV app
  • Twitter
  • UI
  • Uncategorized
  • UX
  • Video
  • Video Conferencing
  • video player
  • Visualization
  • Wallet
  • Wallpapers
  • Watch
  • Weather
  • web app
  • Web Scraping
  • website
  • WeChat
  • Widgets
  • WooCommerce
  • wrapper
  • XML
  • Yoga

  • About US
  • Privacy Policy
  • Submit App
  • Web Stories
    • Free Online Food Delivery Apps for Business
    • Top 5 Flutter Applicatons – Open Source
    • Free Food Ordering App
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPT
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT