GithubHelp home page GithubHelp logo

productinfo / kotlinlogger Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qase/kotlinlogger

0.0 1.0 0.0 624 KB

Smart android logger in kotlin.

Home Page: http://www.quanti.cz

License: MIT License

C++ 5.84% Kotlin 92.55% CMake 1.62%

kotlinlogger's Introduction

Release Build Status codebeat badge API License: MIT Maintainer: kidal5 Qase: KotlinLogger

KotlinLogger

Smart android logger written in Kotlin language.

Mostly used in Prague based android develpoment company - Quanti for everything. Product is still being actively developed.

Features

  • Usable in every JVM language including Java/Kotlin/Scala ...
  • Very easy to use
  • No more TAGs, but you can still use them
  • Easy to extend using your own ILogger interface
  • Lot of optional parameters
  • Lightweight
  • Possibility to print system info
  • Send data to Qase LoggingServer
  • Every logged exception is logged to own separate file
  • Sample app is ready to build

Installation

Click HERE.

Code example

Usage is simple

  1. Make sure you have set your applicationId in gradle
android{
  defaultConfig{
    applicationId = "your.cool.app"
    ...
  }
  ...
}
  1. Initialise Log and add all needed loggers. Every logger can be initialized using bundle or use default values.
// Log initialisation
Log.initialise(context)

//forwards all log to android logcat
val androidBundle = LoggerBundle(LogLevel.INFO)
Log.addLogger(AndroidLogger(androidBundle))

//default log level is warn
//apply plugins google-services and firebase.crashlytics, copy google-services.json in app/ directory
//download google-services.json from https://console.firebase.google.com/u/0/project/{project_id}/settings/general/android:{project_package}
//add these two lines in app/build.gradle
//  apply plugin: 'com.google.gms.google-services'
//  apply plugin: 'com.google.firebase.crashlytics'
Log.addLogger(CrashlyticsLogger())

//Every LogBundles has ton of options, see javadoc for more
//DayLogBundle logs every day to one separate log file
val dayLogBundle = DayLogBundle(maxDaysSaved = 4)
Log.addLogger(FileLogger(applicationContext, dayLogBundle))

//CircleLogBundle logs to one file until specified size is reached, but may overflow
val rotateBundle = CircleLogBundle(numOfFiles = 7)
Log.addLogger(FileLogger(applicationContext, rotateBundle))

//StrictCircleLogBundle logs to one file until specified size is reached, never overflows but slower
val strictRotateBundle = StrictCircleLogBundle(maxFileSizeMegaBytes = 1)  
Log.addLogger(FileLogger(applicationContext, strictRotateBundle))

//WebLogger logs to Qase LogServer using REST API or WebSockets
//Run your own server and then debug your application remotely
val restBundle = RestLoggerBundle("http://webserver/api/v1/")
val webSocketBundle = WebSocketLoggerBundle("ws://webserver/ws/v1/")
Log.addLogger(WebLogger(choose restBundle or webSocketBundle))
  1. Then log as you would normally do - just using another dependency (or log sync using Log.xSync methods)
Log.v("This");
Log.d("is");
Log.i("sample");
Log.i("text", "OWN TAG");
Log.i("that");
Log.i("will");
Log.iSync("be");
Log.w("logged.");
Log.e("wi", Exception()); //throwable
  1. Other possibilities
//Enable unchecked crash handling
Log.useUncheckedErrorHandler()

//Delete all logs
FileLogger.deleteAllLogs()

//Print system logs
Log.logMetadata(appContext)

//Use of SendLogDialogFragment
//It can send zip of logs to email or save to sd card 
//WRITE_EXTERNAL_STORAGE permission is needed if you want to save logs to sd card
SendLogDialogFragment.newInstance("[email protected]", deleteLogs = true).show(supportFragmentManager, "TAG")

License

MIT

kotlinlogger's People

Contributors

kidal5 avatar anezkaquanti avatar petrposvic avatar havlisimo avatar balakzde avatar neubami94 avatar ruzicka1911 avatar zelenmi6 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.