creatint / flutter_simple_log

A simple way to upload logs to remote server.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Language: English | 中文

simple_log

Pub Version Platform

The simplest way to upload logs to remote server, support all platforms.

By default, logs will be uploaded to avenge.app, which is a simple Log-Management-System, welcome to try ^_^

You can set your own server to receive logs.

Getting Started

  1. Register for free

    https://avenge.app/register

  2. Create app

    https://avenge.app/developer/resources/app-apps/new

  3. Install

    dependencies:
        simple_log: ^1.2.3
  4. Usage

    import 'package:simple_log/simple_log.dart';
    
    void main(){
      SimpleLog logger = SimpleLog(appId: yourAppId, appKey: 'yourAppKey');
      FlutterError.onError = (FlutterErrorDetails details) {
        logger.e(details);
      };
      runApp(MyApp());
    }
  5. Other usages

    simple_logger_example.dart

    SimpleLog logger = SimpleLog(appId: 123, appKey: 'yourAppKey');
    SimpleLog logger2 = SimpleLog(key: 'key2',appId: 456, appKey: 'yourAppKey2');
    
    // default key is 'default'
    assert(logger == SimpleLog(key: 'default'));
    
    // debug level
    logger.d('hello world');
    
    // info level
    logger.i('hello world');
    
    // warning level
    logger.w({'a':1,'b':'c'}); 
    
    // error level log will be printed on the local terminal
    logger2.setPrintLevels([Level.Error]);
    
    // error level
    // this log will be printed on the local terminal
    logger2.e(logger); 
    
    // cancel upload logs
    logger2.setUploadLevels(null);
    
    // fatal level
    // this log will be printed on the local terminal but will not be uploaded
    logger2.f(['p1', 'p2']); 

Build receive server

The default value of [SimpleLog.apiPrefix] is 'https://avenge.app/api', you can set your own server to receive logs.

var logger = SimpleLog(apiPrefix: 'your own server');

When it reports a log, it will post a json to remote server:

{
  "app_id": 123,
  "app_key": "appKey123",
  "user": "user123",
  "flag": "flag123",
  "level": 2,
  "data": {}
}

data is the content of the log, it can be string or json.

Then, the remote server will give back a json:

{
  "code": 0,
  "message": "success"
}

If code is 0, it means success.

If something went wrong, it would be:

{
  "code": -1,
  "message": "something wrong ..."
}

全部项目

插件 状态 描述
simple_log Pub Version The simplest way to upload logs to remote server, support all platforms
simple_update Pub Version The simplest way to update your app, support all platforms

About

A simple way to upload logs to remote server.

License:MIT License


Languages

Language:Dart 100.0%