Skip to content

Commit

Permalink
chore: merge branch 'release/1.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ghasemdev committed Aug 22, 2022
2 parents 12207dc + 46ce581 commit 720d5e6
Show file tree
Hide file tree
Showing 136 changed files with 9,152 additions and 364 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [🎉 1.5.0 Structure, Logger, OkHttp] - 2022-08-22

### 🚀 Features

* Add `okhttp-android` module
* okhttp builder extension `okhttpClient {}` , `Response.new {}` and `OkHttpClient.new {}`.
* download and upload progress listener `DownloadStreamResponseBody`, `UploadStreamRequestBody`.
* Add `logger-android` module
* `LogLevel` enum.
* `logcat` extension.
* Singleton `Logger`.

### 💥 Breaking Changes

* Rename checker class from **structure** module.

## [🎉 1.4.0 Structure, Metrica] - 2022-08-21

### 🚀 Features
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Version](https://shields.io/badge/VERSION-1.4.0-blue?style=for-the-badge)](https://github.com/ghasemdev/affogato/releases/tag/1.4.0)
[![Version](https://shields.io/badge/VERSION-1.5.0-blue?style=for-the-badge)](https://github.com/ghasemdev/affogato/releases/tag/1.5.0)
[![Kotlin](https://shields.io/badge/Kotlin-1.7.10-pink?style=for-the-badge)](https://kotlinlang.org/)
[![API](https://shields.io/badge/Api-+21-green?style=for-the-badge)](https://www.android.com/)
[![License MIT](https://shields.io/badge/LICENSE-MIT-orange?style=for-the-badge)](https://opensource.org/licenses/MIT)
Expand Down Expand Up @@ -92,7 +92,7 @@ dimen.icon // 80.dp in device with width 480.dp
# Links

Affogato is currently available for maven/gradle builds
at [Jitpack](https://jitpack.io/#ghasemdev/affogato/1.4.0) (
at [Jitpack](https://jitpack.io/#ghasemdev/affogato/1.5.0) (
read [Getting started](https://github.com/ghasemdev/affogato/wiki/Getting-Started)).

* [Wiki](https://github.com/ghasemdev/affogato/wiki)
Expand Down
4 changes: 1 addition & 3 deletions affogato-core-ktx/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ tasks.test {
dependencies {
// Serialization ---------------------------------------------------------------------------------
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.0")

// Immutable Collections -------------------------------------------------------------------------
api("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.5")

// DateTime --------------------------------------------------------------------------------------
api("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")

Expand All @@ -47,7 +45,7 @@ afterEvaluate {
create<MavenPublication>("java") {
groupId = "com.parsuomash.affogato"
artifactId = "affogato-core-ktx"
version = "1.4.0"
version = "1.5.0"

from(components["java"])
}
Expand Down
20 changes: 1 addition & 19 deletions affogato-coroutines-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,6 @@ plugins {
android {
compileSdk = 33
buildToolsVersion = "33.0.0"

defaultConfig {
minSdk = 21
targetSdk = 33

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
Expand All @@ -51,7 +33,7 @@ afterEvaluate {
create<MavenPublication>("release") {
groupId = "com.parsuomash.affogato"
artifactId = "affogato-coroutines-android"
version = "1.4.0"
version = "1.5.0"

from(components["release"])
}
Expand Down
Empty file.
21 changes: 0 additions & 21 deletions affogato-coroutines-android/proguard-rules.pro

This file was deleted.

2 changes: 1 addition & 1 deletion affogato-coroutines-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ afterEvaluate {
create<MavenPublication>("java") {
groupId = "com.parsuomash.affogato"
artifactId = "affogato-coroutines-core"
version = "1.4.0"
version = "1.5.0"

from(components["java"])
}
Expand Down
2 changes: 2 additions & 0 deletions affogato-logger-android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
.gradle
33 changes: 33 additions & 0 deletions affogato-logger-android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
plugins {
id("com.android.library")
kotlin("android")
id("maven-publish")
}

android {
compileSdk = 33
buildToolsVersion = "33.0.0"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
apiVersion = "1.7"
languageVersion = "1.7"
jvmTarget = "11"
}
}

afterEvaluate {
publishing {
publications {
create<MavenPublication>("release") {
groupId = "com.parsuomash.affogato"
artifactId = "affogato-logger-android"
version = "1.5.0"

from(components["release"])
}
}
}
}
2 changes: 2 additions & 0 deletions affogato-logger-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.parsuomash.affogato.logger.android" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.parsuomash.affogato.logger.android

/**
* ### Top-level logging.
*
* Example :
* ```kotlin
* logcat { "Hello, Napier" }
* logcat(tag = "your tag") { "Hello, Napier" }
* ```
* @since 1.5.0
* @param priority enum: The priority/type of this log message Value is ASSERT,
* ERROR, WARN, INFO, DEBUG, or VERBOSE
* @param throwable Throwable: An exception to log This value may be null.
* @param tag String: Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs. This value may be null.
* @param message Lambda: The message you would like logged. This value cannot be null.
* @see Logger
*/
inline fun logcat(
priority: LogLevel = LogLevel.DEBUG,
throwable: Throwable? = null,
tag: String? = null,
message: () -> Any?,
) {
when (priority) {
LogLevel.ASSERT -> Logger.assert(tag, message().toString(), throwable)
LogLevel.VERBOSE -> Logger.verbose(tag, message().toString(), throwable)
LogLevel.DEBUG -> Logger.debug(tag, message().toString(), throwable)
LogLevel.INFO -> Logger.info(tag, message().toString(), throwable)
LogLevel.WARN -> Logger.warn(tag, message().toString(), throwable)
LogLevel.ERROR -> Logger.error(tag, message().toString(), throwable)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.parsuomash.affogato.logger.android

/**
* LogLevel show priority of log message.
* @since 1.5.0
* @see Logger
*/
enum class LogLevel {
VERBOSE, DEBUG, INFO, WARN, ERROR, ASSERT
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
@file:Suppress("MemberVisibilityCanBePrivate")

package com.parsuomash.affogato.logger.android

import android.util.Log

/**
* Logging class for manage logcat in debug/release mode.
*
* Example:
* ```kotlin
* with(Logger) {
* tag = "Tick"
* isDebug = BuildConfig.DEBUG
* onRelease = { tag, message, throwable ->
* if (tag != null) {
* YandexMetrica.reportError(tag, message, throwable)
* } else {
* YandexMetrica.reportError(message, throwable)
* }
* }
* Logger.info(message = "Hello world!")
* ```
* @since 1.5.0
* @see logcat
*/
object Logger {
/**
* Logging tag help for beter filter and search.
* @since 1.5.0
*/
var tag: String = "Logger"

/**
* When is true printing logs, otherwise run onRelease block.
* @since 1.5.0
*/
var isDebug: Boolean = true

/**
* With onRelease block we define our api for logging in release mode like use crash service.
* @since 1.5.0
*/
var onRelease: ((tag: String?, message: String, throwable: Throwable) -> Unit)? = null

/**
* Send a VERBOSE log message and log the exception.
* @since 1.5.0
* @param message String: The message you would like logged. This value cannot be null.
* @param throwable Throwable: An exception to log This value may be null.
* @param tag String: Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs. This value may be null.
*/
fun verbose(tag: String?, message: String, throwable: Throwable?) {
if (isDebug) {
if (throwable != null) {
Log.v(tag ?: Logger.tag, message, throwable)
} else {
Log.v(tag ?: Logger.tag, message)
}
} else if (throwable != null && onRelease != null) {
onRelease!!.invoke(tag, message, throwable)
}
}

/**
* Send a DEBUG log message and log the exception.
* @since 1.5.0
* @param message String: The message you would like logged. This value cannot be null.
* @param throwable Throwable: An exception to log This value may be null.
* @param tag String: Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs. This value may be null.
*/
fun debug(tag: String?, message: String, throwable: Throwable?) {
if (isDebug) {
if (throwable != null) {
Log.d(tag ?: Logger.tag, message, throwable)
} else {
Log.d(tag ?: Logger.tag, message)
}
} else if (throwable != null && onRelease != null) {
onRelease!!.invoke(tag, message, throwable)
}
}

/**
* Send a INFO log message and log the exception.
* @since 1.5.0
* @param message String: The message you would like logged. This value cannot be null.
* @param throwable Throwable: An exception to log This value may be null.
* @param tag String: Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs. This value may be null.
*/
fun info(tag: String?, message: String, throwable: Throwable?) {
if (isDebug) {
if (throwable != null) {
Log.i(tag ?: Logger.tag, message, throwable)
} else {
Log.i(tag ?: Logger.tag, message)
}
} else if (throwable != null && onRelease != null) {
onRelease!!.invoke(tag, message, throwable)
}
}

/**
* Send a WARN log message and log the exception.
* @since 1.5.0
* @param message String: The message you would like logged. This value cannot be null.
* @param throwable Throwable: An exception to log This value may be null.
* @param tag String: Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs. This value may be null.
*/
fun warn(tag: String?, message: String, throwable: Throwable?) {
if (isDebug) {
if (throwable != null) {
Log.w(tag ?: Logger.tag, message, throwable)
} else {
Log.w(tag ?: Logger.tag, message)
}
} else if (throwable != null && onRelease != null) {
onRelease!!.invoke(tag, message, throwable)
}
}

/**
* Send a ERROR log message and log the exception.
* @since 1.5.0
* @param message String: The message you would like logged. This value cannot be null.
* @param throwable Throwable: An exception to log This value may be null.
* @param tag String: Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs. This value may be null.
*/
fun error(tag: String?, message: String, throwable: Throwable?) {
if (isDebug) {
if (throwable != null) {
Log.e(tag ?: Logger.tag, message, throwable)
} else {
Log.e(tag ?: Logger.tag, message)
}
} else if (throwable != null && onRelease != null) {
onRelease!!.invoke(tag, message, throwable)
}
}

/**
* What a Terrible Failure: Report an exception that should never happen.
* @since 1.5.0
* @param message String: The message you would like logged. This value cannot be null.
* @param throwable Throwable: An exception to log This value may be null.
* @param tag String: Used to identify the source of a log message. It usually
* identifies the class or activity where the log call occurs. This value may be null.
*/
fun assert(tag: String?, message: String, throwable: Throwable?) {
if (isDebug) {
if (throwable != null) {
Log.wtf(tag ?: Logger.tag, message, throwable)
} else {
Log.wtf(tag ?: Logger.tag, message)
}
} else if (throwable != null && onRelease != null) {
onRelease!!.invoke(tag, message, throwable)
}
}
}
Loading

0 comments on commit 720d5e6

Please sign in to comment.