A light lib that helps and centralize logs in your application.

Overview

BadgeLog (Kotlin version)

For the iOS swift version, see this page

BadgeLog is an Android Kotlin library that helps you manage logs within your application:

  • Centralize all log management logic
  • Print console logs in a nice way and customize it.
  • Ability to save logs to file and export them

Installation

repositories {
  mavenCentral()
}

dependencies {
   implementation 'com.danielebachicchi.badgelogk:badgelogk:0.1.0'
}

Configure

Setting up the library is very quick and easy. You need to invoke the following method:

Logger.setup(ConsoleDestination())

This will setup Logger with the funcionality to print logs into Logcat. If you want to save log in file also, just add any destination you want in setup():

Logger.setup(ConsoleDestination(), FileDestination())

I recommend to call setup() within the initialization of the App or in any case as soon as possible.

The library is ready to log! to log in, simply call up:

Logger.verbose("I'm a verbose log!")
Logger.debug("I'm a debug log!")
Logger.info("I'm a info log!")
Logger.warning("I'm a warning log!")
Logger.error("I'm an error log!")
Logger.error("I am an error with exception log!", Throwable("Custom Fake Exception"))

LogDestination

LogDestination is a source that will print the logs in different destination. Every Log request will be dispatched into every Destination added during setup()

At the moment there are this destination templates:

  • ConsoleDestination: will print logs inside Logcat. You can specify the single row format and the min log level.
  • FileDestination: will print logs inside files. You can specify the path, the min log level and the single row format.

You can create a custom LogDestination. Just subclass LogDestination and handle the log row string inside send() method. This example show how ConsoleDestination handle its logic inside send() method:

override fun send(
        level: Logger.LogLevel,
        message: String,
        error: Throwable?,
        tag: String,
        file: String,
        method: String,
        line: Int
    ): String {
        //call super to retrive the formatted log row string
        val result = super.send(level, message, error, tag, file, method, line)
        //if return empty string, it means that the minLevel is greater that log row level
        if (result.isEmpty())
            return ""

        when(level) {
            Logger.LogLevel.VERBOSE -> Log.v(tag, result, error)
            Logger.LogLevel.DEBUG -> Log.d(tag, result, error)
            Logger.LogLevel.INFO -> Log.i(tag, result, error)
            Logger.LogLevel.WARNING -> Log.w(tag, result, error)
            Logger.LogLevel.ERROR -> Log.e(tag, result, error)
        }
        return result
    }

Log Format

For each LogDestination, you can set the format in which they will display the logs. The format is a string that can contain custom characters and preset values. Insert your own custom character inside apex. The default format is

"T '-' L '-' '['c':'l']' M e"

2022-02-08T13:00:00Z - VERBOSE - [ContentView:18] I'm a log!

The default format for ConsoleDestination is:

"'['m':'l']' M"

VERBOSE [ContentView:18] I'm a log!

Preset Char (case sensitive) are:

  • M -> the message of the log.
  • m -> the function name where the log has been requested
  • L -> the LogLevel type (VERBOSE, DEBUG, INFO....)
  • l -> the line number of the file where the log has been requested
  • f -> the file name, fullpath, where the log has been requested
  • c -> the file name, without path, where the log has been requested
  • e -> the NSError of the log, if present.
  • T -> the date of the log, formatted with var dateFormat of the LogDestination.
  • t -> the tag of the log.
  • " " -> empty space.

Requirements

  • Min SDK 21

License

BadgeLog is available under the MIT license. See the LICENSE file for more info.

You might also like...
A android platform i.e, App that helps marriage/party halls and individuals to connect to the nearest places where this food could feed those in need and food wastage is minimised

(Muskan- The joy of giving by nature) , a android platform i.e, App that helps marriage/party halls and individuals to connect to the nearest places where this food could feed those in need and food wastage is minimised.

A nice weather that helps you get all information including: current weather, hourly weather and also forecasts for 16 days
A nice weather that helps you get all information including: current weather, hourly weather and also forecasts for 16 days

WeatherForecast This is an ongoing project where I fetch all the weather data using Retrofit and Kotlin Coroutines over two APIs containing both curre

Runtime Mobile Security (RMS) ๐Ÿ“ฑ๐Ÿ”ฅ  - is a powerful web interface that helps you to manipulate Android and iOS Apps at Runtime
Runtime Mobile Security (RMS) ๐Ÿ“ฑ๐Ÿ”ฅ - is a powerful web interface that helps you to manipulate Android and iOS Apps at Runtime

Runtime Mobile Security (RMS) ๐Ÿ“ฑ ๐Ÿ”ฅ by @mobilesecurity_ Runtime Mobile Security (RMS), powered by FRIDA, is a powerful web interface that helps you to

This program will read from your android application string.xml file and generate translated strings.xml files in your preferred languages using google sheet.
This program will read from your android application string.xml file and generate translated strings.xml files in your preferred languages using google sheet.

Localize your application content This program will read from your application string.xml file and generate translated strings.xml files in your prefe

The Action helps you to send a message to a queue on a RabbitMQ running Server

Rabbit Sender Action This Action helps you to send a message to a queue on a RabbitMQ running Server. Inputs Arg Default Description RABBIT_USERNAME g

Real life Kotlin Multiplatform project with an iOS application developed in Swift with SwiftUI, an Android application developed in Kotlin with Jetpack Compose and a backed in Kotlin hosted on AppEngine.

Conferences4Hall Real life Kotlin Multiplatform project with an iOS application developed in Swift with SwiftUI, an Android application developed in K

Reapp is everything you need to build amazing apps with React: a collection of packages that work together, our UI kit, and a CLI that scaffolds your app and includes a server and build system.
Reapp is everything you need to build amazing apps with React: a collection of packages that work together, our UI kit, and a CLI that scaffolds your app and includes a server and build system.

What is it? Reapp is everything you need to build amazing apps with React: a collection of packages that work together, our UI kit, and a CLI that sca

Create an application with Kotlin/JVM and Kotlin/JS, and explore features around code sharing, serialization, server- and client
Create an application with Kotlin/JVM and Kotlin/JS, and explore features around code sharing, serialization, server- and client

Practical Kotlin Multiplatform on the Web ๋ณธ ์ €์žฅ์†Œ๋Š” ์ฝ”ํ‹€๋ฆฐ ๋ฉ€ํ‹ฐํ”Œ๋žซํผ ๊ธฐ๋ฐ˜ ์›น ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์›Œํฌ์ˆ(๊ฐ•์ขŒ)์„ ์œ„ํ•ด ์ž‘์„ฑ๋œ ํ…œํ”Œ๋ฆฟ ํ”„๋กœ์ ํŠธ๊ฐ€ ์žˆ๋Š” ๊ณณ์ž…๋‹ˆ๋‹ค. ์›Œํฌ์ˆ ๊ณผ์ •์—์„œ ์ฝ”ํ‹€๋ฆฐ ๋ฉ€ํ‹ฐํ”Œ๋žซํผ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ”„๋ก ํŠธ์—”๋“œ(front-end)๋Š” Ko

Create an application with Kotlin/JVM and Kotlin/JS, and explore features around code sharing, serialization, server- and client
Create an application with Kotlin/JVM and Kotlin/JS, and explore features around code sharing, serialization, server- and client

Building a Full Stack Web App with Kotlin Multiplatform ๋ณธ ์ €์žฅ์†Œ๋Š” INFCON 2022์—์„œ ์ฝ”ํ‹€๋ฆฐ ๋ฉ€ํ‹ฐํ”Œ๋žซํผ ๊ธฐ๋ฐ˜ ์›น ํ”„๋กœ๊ทธ๋ž˜๋ฐ ํ•ธ์ฆˆ์˜จ๋žฉ์„ ์œ„ํ•ด ์ž‘์„ฑ๋œ ํ…œํ”Œ๋ฆฟ ํ”„๋กœ์ ํŠธ๊ฐ€ ์žˆ๋Š” ๊ณณ์ž…๋‹ˆ๋‹ค. ํ•ธ์ฆˆ์˜จ ๊ณผ์ •์—์„œ ์ฝ”ํ‹€๋ฆฐ ๋ฉ€ํ‹ฐํ”Œ๋žซํผ์„

Releases(v0.1.0)
Owner
Daniele
Writing code, playing games, eating food
Daniele
Simple and light-weight event dispatcher for Kotlin

KDispatcher is a Kotlin EventDispatcher This is light-weight event dispatcher based on KOTLIN priority: Int? = null to subscribe function for sorting

Alexandr Minkin 63 Oct 3, 2022
This lib implements the most common CoroutineScopes used in Android apps.

AndroidCoroutineScopes Starting from 0.26.0 release we should define a scope for new coroutines (docs). To avoid this boilerplate code I've created th

Adriel Cafรฉ 15 Oct 3, 2022
Small lib for recovering stack trace in exceptions thrown in Kotlin coroutines

Stacktrace-decoroutinator Library for recovering stack trace in exceptions thrown in Kotlin coroutines. Supports JVM(not Android) versions 1.8 or high

null 104 Dec 24, 2022
Account-lib - A suite of libraries to facilitate the usage of account-sdk

Usage Clone this repository (skip this step if the repo is on your local machine). The default branch is fine. git clone https://github.com/AFBlockcha

null 0 May 24, 2022
An android lib that provides most commonly used utility function

Awesome-Utility An android lib that provides most commonly used utility function. It can help Android developers with supporting common utility functi

Ameer Hamza 2 Apr 5, 2022
A light weight Compose Animation library to choreograph low level Animation API through Kotlin DSL.

Koreography Choreograph your Compose Animation ?? ?? A lightweight Compose Animation utility library to choreograph low-level Animation API (https://d

Sagar Viradiya 107 Jan 8, 2023
Oratio Library for Android Studio helps you simplify your Android TTS codes

Oratio Oratio is a library for Android Studio. This library is useful to a number of developers who are currently making apps using android TTS(Text-T

Jacob Lim 1 Oct 28, 2021
A simple xposed module that helps you fully control your location.

FuckLocation An simple xposed module that helps you fully control your location. ไธ€ไธชๅฏไปฅๅธฎๅŠฉไฝ ๅฎŒๅ…จๆŽงๅˆถไฝ็ฝฎๆŽˆๆƒ็š„ๆจกๅ— Currently, you may return custom location to speci

null 218 Dec 30, 2022
A sample project that helps to start building a Mobile Kotlin Multiplatform application

Mobile Kotlin multiplatform project template A sample project that helps to start building a Mobile Kotlin Multiplatform application. It establishes a

Dizel 0 Oct 16, 2021
Utility for developers and QAs what helps minimize time wasting on writing the same data for testing over and over again. Made by Stfalcon

Stfalcon Fixturer A Utility for developers and QAs which helps minimize time wasting on writing the same data for testing over and over again. You can

Stfalcon LLC 31 Nov 29, 2021