dokilog

dokilog / com.dokidevs.dokilog / LogProfile

LogProfile

open class LogProfile

Log profile which can be extended to customise log format.

Parameters

profileName - Unique name for the profile. See DokiLog.addProfile.

Constructors

Name Summary
<init> LogProfile(profileName: String)
Log profile which can be extended to customise log format.

Properties

Name Summary
callStackIndex var callStackIndex: Int
Index for the StackTraceElement in getStackTraceElement. This is dependent on your code. For this library, callStackIndex = 3. Do not override this unless you are overriding other methods and the StackTraceElement returned is incorrect.
filterTag var filterTag: String
Custom tag used for filtering when going through logcat. Default = “Doki”. By default, this is included in getTag as part of the tag.
profileName val profileName: String
Unique name for the profile. See DokiLog.addProfile.

Functions

Name Summary  
adjustPriority open fun adjustPriority(priority: Int): Int
Adjust the priority for certain conditions. By default, there is no adjustment. Source code shows how to change the priority based on device manufacturer.
 
equals open fun equals(other: Any?): Boolean  
getStackTraceElement open fun getStackTraceElement(): StackTraceElement
Get the related StackTraceElement where the parent method is called. It will contain useful information such as className, methodName, lineNumber etc. Override this only if the StackTraceElement returned is incorrect.
 
getStackTraceString open fun getStackTraceString(t: Throwable): String
Method to get stack trace from Throwable. This is from Timber (by Jake Wharton) which unhides UnknownHostException, compared to default Android Log.getStackTraceString().
 
getTag open fun getTag(className: String, stackTraceElement: StackTraceElement): String
Get defined tag for the log. Default has the format of “$filterTag - $className
${stackTraceElement.methodName}”
hashCode open fun hashCode(): Int  
isLoggable open fun isLoggable(priority: Int): Boolean
Sets the condition to log based on priority. Default = true.
 
log open fun log(priority: Int, tag: String?, message: String): Unit
Actual log method. This is from Timber (by Jake Wharton) to split log according to maximum length defined by MAX_LOG_LENGTH.
 
prepareLog open fun prepareLog(priority: Int, t: Throwable? = null, message: String?, className: String): Unit
Entry point to the whole logging process. Prepare log based on message and throwable. If both are null, the message is set as “called”, so that no message is swallowed. This is useful for checking the method calls sequence. For example, simply call v(), d(), etc. anywhere and it will return “methodName: called”.
 

Companion Object Properties

Name Summary
MAX_LOG_LENGTH const val MAX_LOG_LENGTH: Int
MAX_TAG_LENGTH const val MAX_TAG_LENGTH: Int