-
Notifications
You must be signed in to change notification settings - Fork 6
Add Logger module #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| IS_ANDROID_PROJECT=false | ||
| POM_ARTIFACT_ID=annotations-processor | ||
| POM_ARTIFACT_GROUP_ID=com.mapbox.base | ||
| POM_ARTIFACT_TITLE=Mapbox Annotations Processor | ||
| POM_DESCRIPTION=Artifact that provides Mapbox module and plugin generators |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| IS_ANDROID_PROJECT=false | ||
| POM_ARTIFACT_ID=annotations | ||
| POM_ARTIFACT_GROUP_ID=com.mapbox.base | ||
| POM_ARTIFACT_TITLE=Mapbox Annotations | ||
| POM_DESCRIPTION=Artifact that provides Mapbox module and plugin annotations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| IS_ANDROID_PROJECT=true | ||
| POM_ARTIFACT_ID=common | ||
| POM_ARTIFACT_GROUP_ID=com.mapbox.base | ||
| POM_ARTIFACT_TITLE=Mapbox Common | ||
| POM_DESCRIPTION=Artifact that provides Mapbox module and plugin contracts |
59 changes: 59 additions & 0 deletions
59
common/src/main/java/com/mapbox/base/common/logger/Logger.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package com.mapbox.base.common.logger | ||
|
|
||
| import com.mapbox.base.common.logger.model.Message | ||
| import com.mapbox.base.common.logger.model.Tag | ||
|
|
||
| /** | ||
| * Logger definition | ||
| */ | ||
| interface Logger { | ||
| /** | ||
| * Send a verbose log message and log the exception. | ||
| * | ||
| * @param tag is [Tag] used to identify the source of a log message. It usually identifies | ||
| * the class or activity where the log call occurs. | ||
| * @param msg is [Message] you would like logged. | ||
| * @param tr An exception to log | ||
| */ | ||
| fun v(tag: Tag? = null, msg: Message, tr: Throwable? = null) | ||
|
|
||
| /** | ||
| * Send a debug log message and log the exception. | ||
| * | ||
| * @param tag is [Tag] used to identify the source of a log message. It usually identifies | ||
| * the class or activity where the log call occurs. | ||
| * @param msg is [Message] you would like logged. | ||
| * @param tr An exception to log | ||
| */ | ||
| fun d(tag: Tag? = null, msg: Message, tr: Throwable? = null) | ||
|
|
||
| /** | ||
| * Send an info log message and log the exception. | ||
| * | ||
| * @param tag is [Tag] used to identify the source of a log message. It usually identifies | ||
| * the class or activity where the log call occurs. | ||
| * @param msg is [Message] you would like logged. | ||
| * @param tr An exception to log | ||
| */ | ||
| fun i(tag: Tag? = null, msg: Message, tr: Throwable? = null) | ||
|
|
||
| /** | ||
| * Send a warning log message and log the exception. | ||
| * | ||
| * @param tag is [Tag] used to identify the source of a log message. It usually identifies | ||
| * the class or activity where the log call occurs. | ||
| * @param msg is [Message] you would like logged. | ||
| * @param tr An exception to log | ||
| */ | ||
| fun w(tag: Tag? = null, msg: Message, tr: Throwable? = null) | ||
|
|
||
| /** | ||
| * Send an error log message and log the exception. | ||
| * | ||
| * @param tag is [Tag] used to identify the source of a log message. It usually identifies | ||
| * the class or activity where the log call occurs. | ||
| * @param msg is [Message] you would like logged. | ||
| * @param tr An exception to log | ||
| */ | ||
| fun e(tag: Tag? = null, msg: Message, tr: Throwable? = null) | ||
| } |
8 changes: 8 additions & 0 deletions
8
common/src/main/java/com/mapbox/base/common/logger/model/Message.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.mapbox.base.common.logger.model | ||
|
|
||
| /** | ||
| * Wrapper class for loggers message. | ||
| * | ||
| * @param message The message you would like logged. | ||
| */ | ||
| data class Message(val message: String) |
9 changes: 9 additions & 0 deletions
9
common/src/main/java/com/mapbox/base/common/logger/model/Tag.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.mapbox.base.common.logger.model | ||
|
|
||
| /** | ||
| * Wrapper class for loggers tag. | ||
| * | ||
| * @param tag used to identify the source of a log message. It usually identifies | ||
| * the class or activity where the log call occurs. | ||
| */ | ||
| data class Tag(val tag: String) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| plugins { | ||
| id("com.android.library") | ||
| kotlin("android") | ||
| kotlin("kapt") | ||
| id("com.jaredsburrows.license") | ||
| id("org.jetbrains.dokka-android") | ||
| } | ||
|
|
||
| android { | ||
| compileSdkVersion(AndroidVersions.compileSdkVersion) | ||
|
|
||
| defaultConfig { | ||
| minSdkVersion(AndroidVersions.minSdkVersion) | ||
| targetSdkVersion(AndroidVersions.targetSdkVersion) | ||
| testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| compileOnly(project(":annotations")) | ||
| kapt(project(":annotations-processor")) | ||
| implementation(project(":common")) | ||
| implementation(Dependencies.kotlin) | ||
|
|
||
| /** | ||
| * Required for @Keep annotation by the annotation-processor and the resulting generated code | ||
| */ | ||
| implementation(Dependencies.annotations) | ||
|
|
||
| testImplementation(Dependencies.junit) | ||
| testImplementation(Dependencies.mockk) | ||
| } | ||
|
|
||
| project.apply { | ||
| from("$rootDir/gradle/ktlint.gradle") | ||
| from("$rootDir/gradle/lint.gradle") | ||
| from("$rootDir/gradle/android-artifacts.gradle") | ||
| from("$rootDir/gradle/bintray-publish.gradle") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| IS_ANDROID_PROJECT=true | ||
| POM_ARTIFACT_ID=logger | ||
| POM_ARTIFACT_GROUP_ID=com.mapbox.common | ||
| POM_ARTIFACT_TITLE=Mapbox Logger | ||
| POM_DESCRIPTION=Artifact that provides Mapbox Logger module implementation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| <manifest package="com.mapbox.common.logger" /> |
15 changes: 15 additions & 0 deletions
15
liblogger/src/main/java/com/mapbox/common/logger/LogEntry.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.mapbox.common.logger | ||
|
|
||
| /** | ||
| * Model of Log entry. | ||
| * | ||
| * @property tag The tag you would like your message will marked. | ||
| * @property message The message you would like logged. | ||
| * @property throwable The throwable you would like to log. | ||
| * @constructor Creates an [LogEntry] | ||
| */ | ||
| data class LogEntry( | ||
| val tag: String?, | ||
| val message: String, | ||
| val throwable: Throwable? | ||
| ) |
49 changes: 49 additions & 0 deletions
49
liblogger/src/main/java/com/mapbox/common/logger/LogPriority.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| @file:JvmName("LogPriority") | ||
|
|
||
| package com.mapbox.common.logger | ||
|
|
||
| import android.util.Log | ||
|
|
||
| /** | ||
| * Priority constant for the println method; use Logger.v | ||
| * | ||
| * This log priority will print all logs. | ||
| */ | ||
| const val VERBOSE = Log.VERBOSE | ||
|
|
||
| /** | ||
| * Priority constant for the println method; use Logger.d. | ||
| * | ||
| * This log priority will print all logs except verbose. | ||
| */ | ||
| const val DEBUG = Log.DEBUG | ||
|
|
||
| /** | ||
| * Priority constant for the println method; use Logger.i. | ||
| * | ||
| * This log priority will print all logs except verbose and debug. | ||
| * | ||
| */ | ||
| const val INFO = Log.INFO | ||
|
|
||
| /** | ||
| * Priority constant for the println method; use Logger.w. | ||
| * | ||
| * This log priority will print only warn and error logs. | ||
| * | ||
| */ | ||
| const val WARN = Log.WARN | ||
|
|
||
| /** | ||
| * Priority constant for the println method; use Logger.e. | ||
| * | ||
| * This log priority will print only error logs. | ||
| */ | ||
| const val ERROR = Log.ERROR | ||
|
|
||
| /** | ||
| * Priority constant for the println method. | ||
| * | ||
| * This log priority won't print any logs. | ||
| */ | ||
| const val NONE = 99 |
17 changes: 17 additions & 0 deletions
17
liblogger/src/main/java/com/mapbox/common/logger/LoggerObserver.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.mapbox.common.logger | ||
|
|
||
| import com.mapbox.common.logger.annotations.LogLevel | ||
|
|
||
| /** | ||
| * Interface for observe logs we want to catch | ||
| */ | ||
| interface LoggerObserver { | ||
|
|
||
| /** | ||
| * Calls when [MapboxLogger] was log any [LogEntry]. | ||
| * | ||
| * @param level is [LogLevel] used to identify the level of logged [LogEntry] | ||
| * @param entry is logged [LogEntry]. | ||
| */ | ||
| fun log(@LogLevel level: Int, entry: LogEntry) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.