Skip to content

This is an annotation processor that will generate an appropriate log tag for Android Log messages.

License

Notifications You must be signed in to change notification settings

chrimaeon/logtag-kapt

Repository files navigation

Log TAG Annotation Processor Build & Test codecov

License MavenCentral

This is an annotation processor that will generate an appropriate log tag for Android Log messages

Usage

Setup

using KSP

The library supports KSP (Kotlin Symbol Processing API)

Add the processor and annotation libraries to the projects dependencies

dependencies {
    implementation("com.cmgapps:log-tag:1.1.0")
    ksp("com.cmgapps:log-tag-processor:1.1.0")
}

also get sure to apply the KSP Gradle Plugin

plugins {
    id("com.google.devtools.ksp") version "1.1.0"
}
using KAPT

Add the processor and annotation libraries to the projects dependencies

dependencies {
    implementation("com.cmgapps:log-tag:1.1.0")
    kapt("com.cmgapps:log-tag-processor:1.1.0")
}

also get sure to apply the Annotation Processor Plugin

plugins {
    kotlin("kapt")
}

Code

In your source file add the com.cmgapps.LogTag annotation to the class file you want to have a log tag generated:

@com.cmgapps.LogTag
class SuperImportantClass
  • For Kotlin classes this will generate an extension property to you class called LOG_TAG you can then use as the tag for your android log messages.

  • For Java it will generate a class called <Classname>LogTag which has a constant field called LOG_TAG you can then import to tag your android log messages

  • For Jetpack Compose you can annotate the @Composable function for the processor to generate a class called Composable<Composable function name> with a companion object property LOG_TAG

License

Copyright (c) 2021. Christian Grach <[email protected]>

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.