Skip to content

Instantly share code, notes, and snippets.

@cp-hardik-p
Last active September 30, 2022 12:04
Show Gist options
  • Save cp-hardik-p/0ba380b091e0719175b5fb0c4b5ebda8 to your computer and use it in GitHub Desktop.
Save cp-hardik-p/0ba380b091e0719175b5fb0c4b5ebda8 to your computer and use it in GitHub Desktop.
private val maxLogSize = 5 * 1024 * 1024 // 5 MB
private val dateFormat = SimpleDateFormat("yyyy-MM-dd hh:mm:ss:SSS", Locale.US)
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
if (priority >= Log.DEBUG) {
val log = generateLog(priority, tag, message)
if (!logFile.exists()) {
logFile.createNewFile()
}
writeLog(logFile, log)
ensureLogSize(logFile)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment