Code Monkey home page Code Monkey logo

android-library-and-sample-template's Introduction

##########################

##########################

Latest GitHub release

Go to Documentation

What is PinLog?

Using PinLog, you can store your logs in a sql database and also save them in a file on android without writing hundreds of lines of code.

//Logs are automatically stored.
PinLog.logI("MainActivity","onCreate")

//Or create a report which contains 
//PinLogs, applicationInfo, BuildConfig if was 
//provided while initialisation and System logs.
PinLog.CrashReporter().createReport(thread,exception)

//Get stored logs 
PinLog.getAllPinLogsAsStringList() 

//Delete stored logs 
PinLogs.deleteAllPinLogs()

PinLog also supports Uncaught Exception Handling, which you can use like this :

PinLog.setupExceptionHandler(
toEmails = arrayOf("[email protected]"), 
message ="You can add additional comments 
in this email which may help us a lot.",
subject =  "Sorry MyApplication crashed, 
we will try better next time.")

PinLog is an easy-to-use and powerful android Logging Library. It is made by Aditya Bavadekar.

PinLog supports storing logs for later retrieval, saving logs in a file, saving logs in a zip file and more.

This project contains two modules i.e libraries namely pinlog the main library and pinlog-activity the extension library. The main library does not depend on the other library, so you can use it directly from dependency.

What is pinlog-activity?

PinLog-Activity is an extension library for PinLog usefull for debuging and finding bug by isolation of logs.

Many times we have to debug apps by connecting the android device to pc just to view the logs from logcat.

Pinlog-activity is an on-device app which is installed with your application. When you open it you can see all the pinlogs added by your app. You can filter the logs according to their TAG property or sort them. You can also export all logs to a file with it.

Screenshots of pinlog-activity library

Latest version

For the latest version and a complete changelog, please see the Release page.

Download

You can download a aar or .zip rom this repositor's releases page.

Or you can clone the whole repository with

git clone https://github.com/AdityaBavadekar/PinLog

Implementation

Using Gradle :

Add maven{ } in your build.gradle(project)

allprojects {
    repositories {
      //Add this `maven` block
      maven { url 'https://jitpack.io' }
    }
}

Add the dependency TAG

dependencies {
     // Refer the above badge for latest `TAG`.
    implementation 'com.github.AdityaBavadekar.PinLog:pinlog:TAG'
    //Or if you want a DebugLogsActivity for 
    //your app which shows list of logs add this instead
    debugImplementation 'com.github.AdityaBavadekar.PinLog:pinlog-activity:TAG'
    
}

Using Maven :

Add repository

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add the dependency TAG

	<dependency>
	    <groupId>com.github.AdityaBavadekar.PinLog</groupId>
	    <artifactId>pinlog</artifactId>
	    <version>TAG</version>
	</dependency>
<!--Or if you want a DebugLogsActivity for 
     your app which shows list of logs add this instead-->
	<dependency>
	    <groupId>com.github.AdityaBavadekar.PinLog</groupId>
	    <artifactId>pinlog-activity</artifactId>
	    <version>TAG</version>
	</dependency>

How do I use PinLog?

Initialisation

  • PinLog should be initialised in the Application Class :
class App : Application() {

    override fun onCreate() {
        super.onCreate()

         PinLog.initialise(this)
         PinLog.setDevLogging(true)//Optional
         PinLog.setBuildConfigClass(BuildConfig::class.java)//Optional
    }

}

OR

 //For Debuggable Builds
 PinLog.initialiseDebug(this@App)

 //For Release Builds
 PinLog.initialiseRelease(this@App)

Usage

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        logI("onCreate")
        logW("This is a warning")
        logE("This is a error")
        logD("This is a debug log")
        //OR
        PinLog.logI("MainActivity","onCreate")
        PinLog.logW("MainActivity","This is a warning")
        PinLog.logE("MainActivity","This is a error")
        PinLog.logD("MainActivity","This is a debug log")

        //Get stored logs
        PinLog.getAllPinLogsAsStringList()
        //Delete stored logs
        PinLogs.deleteAllPinLogs()

    }

}

You can customise the log format by extending LoggingStyle class and configuring it with PinLog by calling

PinLog.setLogFormatting(myCustomLoggingStyle)

But the default implementation that is in the class called as DefaultApplicationLoggingStyle Which has output similar to this line.

Vr/[0.0.1-debug] Mon Jul 04 14:13:44 GMT+05:30 2022/ D/AuthFragment : onPause

Documentation

A complete documentation is available here.

Sample

A sample called Pinlog Sample pinlogsample is included in the source, which demonstrates common and simple usage of PinLog library. You can find debug-apks for same app in the latest relaeses.

View Sample App Download Sample App

Dependencies used

Following are dependencies that were used for pinlog-activity module.

  • Kotlin Coroutines
  • Recyclerview

Author

@Aditya Bavadekar on GitHub

Licence


   Copyright 2022 Aditya Bavadekar

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

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

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

android-library-and-sample-template's People

Contributors

adityabavadekar avatar

Watchers

 avatar

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.