Giter VIP home page Giter VIP logo

slog's Introduction

SuperLog

输出到控制台 输出到文件

轻量级Log日志框架,支持输出到控制台和文件等支持自定义扩展。 输出到文件的Log以自定义 Tag 作为文件名,单个日志文件限制大小为4M。

功能说明

  1. 输出Log到控制台
  2. 输出Log到文件
  3. 可扩展输出Log到其他介质
  4. 支持自定义Tag
  5. 支持输出线程信息
  6. 支持输出调用堆栈信息
  7. 支持Log定位
  8. 支持输出格式自定义
  9. 支持多线程环境

使用说明

  1. 添加依赖
implementation 'io.github.heartinfei:slogger:1.0.4'
  1. 初始化
public class SApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        S.init(this);
        if (BuildConfig.DEBUG) {
            S.addPlant(new DebugPlan());    //输出到控制台
        } else {
            S.addPlant(new ReleasePlan(path)); //输出到文件
        }
    }
}
  1. 使用
//普通输出
S.i("Test");

//Error输出
S.e(...);

//自定义Tag
S.log("MyTag","Message .....");

  1. 自定义Configuration
Configuration config = new Configuration.Builder(this)
               .trackInfoDeep(Integer.MAX_VALUE) //打印堆栈深度
               //确保你的包名和源码包一致,如果你的程序存在多个构建这里需要注意否则堆栈信息可能不正确
               .pkgName(BuildConfig.APPLICATION_ID)
               .tag("S_LOG")           //default is Application name
               .isPrintLineNo(true)    //打印行号 defaut true
               .isPrintTag(true)       //打印Tag defaut true
               .isPrintTrackInfo(true) //打印堆栈 defaut true
               .isPrintThreadInfo(true)//打印线程信息 defaut true
               .build();
S.addConfig(config);
  1. 扩展Log输出方式 通过继承BasePlan可创建自定义Plan,可参考ReleasePlan的实现

  2. 其他请参考Demo

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.