Coder Social home page Coder Social logo

vlpasha / dart_logging_appenders Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hpoul/dart_logging_appenders

0.0 0.0 0.0 694 KB

Logging appenders for the logging package for print, file and remote (logz, loki).

License: MIT License

Dart 99.00% Shell 1.00%

dart_logging_appenders's Introduction

logging_appenders

Pub codecov

Native dart package for logging appenders usable with the logging package.

Color Output Screenshot

It currently includes appenders for:

Performance of Remote Logging Appenders

I am not sure if it is wise to use this in production, but it's great during beta testing with a handful of users so you have all logs available.

It tries to stay reasonable performant by batching log entries and sending them off only every few seconds. If network is down it will retry later. (with an ever increasing interval).

Getting Started

After installing package logging and logging_appenders:

import 'package:logging/logging.dart';
import 'package:logging_appenders/logging_appenders.dart';

final _logger = Logger('main');

void main() {
  PrintAppender.setupLogging();

  // The above code is the same as:
  // Logger.root.level = Level.ALL;
  // PrintAppender()..attachToLogger(Logger.root);

  _logger.fine('Lorem ipsum');
}

Outputs:

$ dart main.dart
2019-08-19 15:36:03.827563 FINE main - Lorem ipsum

Color Formatter

    PrintAppender(formatter: const ColorFormatter())
        ..attachToLogger(Logger.root);

Produces:

Color Output Screenshot

Logging to stderr

When using dart:io (ie. command line apps) it is possible to define which log levels should go to stderr instead of stdout:

PrintAppender.setupLogging(stderrLevel: Level.SEVERE);

Remote Appenders

Appender for logz.io

  final _logzIoApiSender = LogzIoApiAppender(
    // you can find your API key and the required URL from 
    // the logz.io dashboard: https://app-eu.logz.io/#/dashboard/settings/general
    apiToken: 'MY API KEY',
    url: 'https://listener-eu.logz.io:8071/',
    labels: {'app': 'MyApp', 'os': Platform.operatingSystem},
  );
  _logzIoApiSender.attachToLogger(Logger.root);
  
  
  // ...
  If you know that you no longer need the appender. it's good to dispose it:
  _logzIoApiSender.dispose();

dart_logging_appenders's People

Contributors

hpoul avatar hsmade avatar rvasqz86 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.