Giter Site home page Giter Site logo

sposer / log Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 221 KB

自用安卓开发辅助打印日志类,快捷的日志输出,可自定义数据类型的处理和输出的逻辑

License: Apache License 2.0

Java 25.23% Kotlin 74.77%

log's Introduction

log

自用安卓开发辅助打印日志类,快捷的日志输出,可自定义数据类型的处理和输出的逻辑

使用

  1. 确保repositories中有mavenCentral(),如:

    repositories {
        ...
        mavenCentral()
        ...
    }
  2. 在子目录的build.gradle中添加:

    dependencies {
        //添加的
        implementation "top.heue.utils:log:1.3.0"
    }
  3. 点击Sync Now等待完成

  4. 使用:

    /**
     * 默认处理和输出类
     */
    init {
        TaskPool.apply {
            add(StringHandler())
            add(ThrowableHandler())
            add(JSONHandler())
            add(BundleHandler())
            add(NullHandler())
            add(AnyHandler())
    
            //只输出到控制台
            add(DefaultPrinter())
        }
    }
    
    fun addHandler(handler: IBaseHandler)
    fun addPrinter(printer: IBasePrinter)
    
    fun v(any: Any?)
    fun v(tag: String, any: Any?)
    fun d(any: Any?)
    fun d(tag: String, any: Any?)
    fun i(any: Any?)
    fun i(tag: String, any: Any?)
    fun w(any: Any?)
    fun w(tag: String, any: Any?)
    fun e(any: Any?)
    fun e(tag: String, any: Any?)
    
    /**
     * Throwable To String
     */
    val Throwable.string: String
    
    /**
     * 执行时间计算,调用第二次得到距离前一次时间
     */
    val apart: Long
    
    /**
     * 当前执行方法,类名 to 方法名
     */
    val current: Pair<String, String>
    
    /**
     * 抓取应用崩溃信息,适用于Application中使用,适时处理和重启
     * thread为null表示主线程,否则为出错线程
     */
    fun catchError(threadHandler: (thread: Thread?, throwable: Throwable) -> Unit): L

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.