Code Monkey home page Code Monkey logo

flutter_error_log's Introduction

flutter_error_log

记录项目日志、捕获项目错误、缓存所有记录、写入文件、上传服务器

  • 初始化:
ErrorLog.log = new ErrorLog(
    reportZone: () async {
        runApp(new MyApp());
    },
    debugMode: true,
    uploadFile: (file) async {},
    minutesWait: 30,
    [fileName: 'error_log.txt']
);

项目日志

默认标记的项目日志可以使用相应的方法;自定义标记的项目日志可以使用基础方法。

  • 使用方式:
ErrorLog.log.debug('msg'*8);
ErrorLog.log.info('msg'*8);
ErrorLog.log.warn('msg'*8);
ErrorLog.log.error('msg'*8);
ErrorLog.log.fatal('msg'*8);
ErrorLog.log.collectLog('msg'*8, 'error');  // 都是调用这个基础方法
  • 输出格式:

[2019-04-18 11:50:29.844858][error] msgmsgmsgmsgmsgmsgmsgmsg

错误报告

错误报告的信息比较多,标记为report

  • 使用方式: 自动捕获错误,不包含 try/catch,不包含 print
  • 输出格式:

[2019-04-18 14:05:03.578755][report]

所有错误信息

写入文件

所有记录都缓存在一个数组里,如果debugMode为真,打印到控制台; 否则根据数组索引异步写入文件error_log.txt,在初始化时可传参fileName

  • 使用方式:
ErrorLog.log.printBuffer();  // 打印记录缓存
ErrorLog.log.clearFile();    // 清空记录文件
ErrorLog.log.printFile();    // 打印文件内容

上传服务器

打开应用时上传一次,然后设置计时器,建议30分钟上传一次。调试模式下,没有写入文件,不会调用上传接口。

  • 使用方式: 初始化时传参uploadFileminutesWait,获取记录的文件ErrorLog.log.logFile

设备信息

使用 device_info,应用启动时会获取和记录。

  • 使用方式:
await ErrorLog.log.getDeviceInfo();   // 异步返回设备信息
  • 输出格式: 字符串,Future String

[2019-04-24 10:05:11.413469][info] 设备信息 device_info

[androidInfo] androidId: 1a08f53b320ccfef, ...

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.