Go to Documentation |
---|
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("example@gmail.com"),
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.
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.
For the latest version and a complete changelog, please see the Release page.
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
Add
maven{ }
in your build.gradle(project)
allprojects {
repositories {
//Add this `maven` block
maven { url 'https://jitpack.io' }
}
}
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'
}
Add
repository
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<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>
- 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)
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
A complete documentation is available here.
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 |
---|
Following are dependencies that were used for pinlog-activity
module.
- Kotlin Coroutines
- Recyclerview
@Aditya Bavadekar on GitHub
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.