GithubHelp home page GithubHelp logo

ruolidevelop / cherrilog Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cranyozen/cherrilog

0.0 0.0 0.0 294 KB

Perhaps the simplest and most useful log library for dart

License: GNU Lesser General Public License v2.1

Dart 100.00%

cherrilog's Introduction

banner

Overview

CherriLog is perhaps the simplest and most useful log library for all dart program

Features

  • Log messages directly by calling static methods
  • Nice stacktrace formatter
  • Custom log levels support
  • Custom loggers:

TODOs

  • Log to file (Full Platform Path Support)
  • Highly customizable log format

Usage

  1. Add the dependency to your pubspec.yaml file
    Recommend to use command line:

    With Flutter

    flutter pub add cherrilog

    With Dart

    dart pub add cherrilog
  2. Import library

    import 'package:cherrilog/cherrilog.dart';
  3. Initialize cherrilog

    CherriLog.init(
      options: CherriOptions()
        ..logLevelRange = CherriLogLevelRanges.all
        ..useBuffer = false,
    ).logTo(CherriConsole()); // Use `CherriFile()` instead of `CherriConsole` if you want to log to file system
  4. Call log methods

    debug('This is a debug message');
    info('This is an info message');
    warning('This is a warning message');
    error('Something went wrong');
    fatal('Oh oh :(');

Log levels

Cherrilog provides a CherriLogLevel class to support custom level, and below is the default instances:

  • CherriLogLevel.fatal: Fatal errors
  • CherriLogLevel.error: Errors
  • CherriLogLevel.warning: Warnings
  • CherriLogLevel.info: Information messages
  • CherriLogLevel.debug: Debug messages

And you will also see nether and upperBond, these two instances is to help with comparison, don't use them directly.

You can find some predefined log level ranges in CherriLogLevelRanges class.

Timestamp Patterns

We offer some preset timestamp formats with in formatter/timestamp.dart.

You can also use your own format.

Output

Demo Outputs

Note: The colors may vary depending on the terminal. This is probably the result on VSCode. Reference

Contributors

Contributors

Star History

Star History Chart

cherrilog's People

Contributors

cranyozen avatar dynesshely avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.