The Android Arsenal – Logging

Table of Contents

⚠️ Error Tracing is FUN! ⚠️


Documentation

Set up

Step 1. Upload the JitPack repository on your construct document .

    allprojects {
        repositories {
            maven { url 'https://jitpack.io' }
        }
    }

Step 2. Upload the dependency.

    dependencies {
            implementation 'com.github.rommansabbir:TraceX:Tag'
    }

Model to be had

Why TraceX?

TraceX is designed to observe all Uncaught Exception happens in app lifecycle by means of default. Additionally, shopper can disable auto tracking Uncaught Exception by means of following the TraceXConfig and manually check in an Process for tracking by means of calling TraceX.registerActivity API.

TraceX will routinely write a log to the app cache listing if the Uncaught Exception is an example of RuntimeException according to Config. Shopper too can write a brand new log the the app cache listing by means of calling TraceX.writeANewLog API.

Additionally, shopper can get all logs written by means of TraceX or shopper itself by means of calling TraceX.writeANewLog API.

Shopper too can take away an inventory of controlled or unmanaged logs from the cache listing this is written by means of TraceX. Or, merely take away all logs from cache listing written by means of TraceX.

Motto of this library:

As a developer we do not know on which tool or on which constraint gadget will throw Exception or RuntimeException if the applying is in PRODUCTION. If any Uncaught Exception happens all the way through app lifecycle we get to find out about it by means of others Logging library.

However, as a developer chances are you’ll need to know navigate the consumer to a selected web page (eg. house web page) when an deadly exception happens which sooner or later kill the applying procedure within the tool. Ahead of that web page navigation, we will write a log to the app cache listing by means of following the present Software Information, Present Thread, Throwable that happened and a JSON object as additional information. Or just, we will write our personal log to the cache listing at our personal.

In order that, we will get the listing written logs from the cache listing when consumer run the applying once more, we will procedure the logs, like SEND IT TO THE REMOTE SERVER for computer virus solving, analytics or just forget about or take away the log from the cache listing.

NOTE: Writing or Studying logs from cache listing follows Encryption/Decryption procedure by means of the use of StoreX.


Find out how to initialize and Get admission to?:

Initialize TraceX out of your Utility.onCreate()

    TraceXProvider.check in(TraceXConfig(this,
        autoRegisterForEachActivity = true,
        autoLogRuntimeExceptions = true
    ))

To Get admission to TraceX name TraceXProvider.INSTANCE which go back an example of TraceX

Public APIs:

  • registerListener(listener: TraceXCallback?), To check in or unregister listener

  • registerActivity(task: Process?): Boolean, Manually check in an actvity for Uncaught Error Match Hanlding and go back Boolean. Additionally, TraceXConfig.autoRegisterForEachActivity will have to be false

  • writeANewLog(throwable: Throwable, additionalInfo: String = ""): Boolean, To write down a brand new encrypted log to the app cache listing and go back Boolean.

  • getRecentCrashLogs(): MutableList<TraceXCrashLog>, To get listing of latest logs from app cache listing. [Note: It’s a CPU Intensive process, execute the operation with Coroutine/RxJava.]

  • clearCrashLogs(listing: MutableList<TraceXCrashLog>), To take away a given listing of TraceXCrashLog from the app cache listing. [Note: It’s a CPU Intensive process, execute the operation with Coroutine/RxJava.]

  • clearAllLogs(): Boolean, To take away all logs from the app cache listing written by means of **TraceX [Note: It’s a CPU Intensive process, execute the operation with Coroutine/RxJava.]


Remeber: All public APIs will throw TraceXNotInitializedException if TraceX isn’t initialized ahead of gaining access to it is APIs.


Checkout the pattern app for the implementaion intimately


Glad Coding….


Touch me

LinkedIn | Weblog


License

Apache Model 2.0

Copyright (C) 2022 Romman Sabbir

Authorized underneath the Apache License, Model 2.0 (the "License");
you won't use this document except for in compliance with the License.
It's possible you'll download a duplicate of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Until required by means of appropriate legislation or agreed to in writing, tool
disbursed underneath the License is sent on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, both categorical or implied.
See the License for the particular language governing permissions and
obstacles underneath the License.