Compare commits

...

76 Commits
0.4.0 ... 1.2.2

Author SHA1 Message Date
d25a73df3d remove unnecessary targets 2023-10-23 01:37:41 +06:00
333cb690a1 get back version of kslog 2023-09-22 01:52:15 +06:00
a3e6ccf973 get back build.gradle 2023-09-22 01:46:05 +06:00
9ce62e13f5 migrate onto build.gradle.kts 2023-09-20 22:27:06 +06:00
e88df8db99 update github workflows java toolchain versions 2023-09-20 21:45:39 +06:00
8613f350e3 update of gradle wrapper and publishing scripts 2023-09-20 21:39:01 +06:00
7fbf80a52a start 1.2.2 2023-09-20 20:04:27 +06:00
00da37e060 Merge pull request #45 from InsanusMokrassar/1.2.1
1.2.1
2023-09-06 19:05:58 +06:00
a779791a00 update dependencies 2023-09-06 19:05:12 +06:00
03cc000306 start 1.2.1 2023-09-06 19:02:59 +06:00
875d2d723e Merge pull request #41 from InsanusMokrassar/1.2.0
1.2.0
2023-07-28 12:21:55 +06:00
01722311e6 update kotlin and add versions plugin 2023-07-28 12:15:01 +06:00
9b994de857 start 1.2.0 2023-07-28 12:15:01 +06:00
a170bbaa5c Merge pull request #39 from InsanusMokrassar/1.1.2
1.1.2
2023-07-28 12:14:28 +06:00
7b8d72e9c0 update test dependencies 2023-06-19 22:47:41 +06:00
0237ec56c5 update dependencies 2023-06-19 22:46:45 +06:00
bef9e0c550 start 1.1.2 2023-06-19 22:40:16 +06:00
d7eb0093d8 Update README.md 2023-06-10 18:16:35 +06:00
deba12ed5d update dokka and gradle wrapper version 2023-06-09 12:08:57 +06:00
f608cf4bef Merge pull request #25 from InsanusMokrassar/renovate/configure
Configure Renovate
2023-04-25 12:27:29 +06:00
renovate[bot]
4a656d2d90 Add renovate.json 2023-04-18 08:23:00 +00:00
c730f49fbd Merge pull request #24 from InsanusMokrassar/1.1.1
1.1.1
2023-04-13 11:09:15 +06:00
2a36f64b51 add actual defaultLogging in wasm 2023-04-13 10:58:07 +06:00
604ef1b347 add wasm support 2023-04-13 10:52:05 +06:00
dc50977c9a KSLog factory fix 2023-04-13 10:33:13 +06:00
7c0650e2df start 1.1.1 2023-04-13 10:31:50 +06:00
387ca9097c Merge pull request #23 from InsanusMokrassar/1.1.0
1.1.0
2023-04-12 23:21:54 +06:00
a71405aff5 small improvements in KSLog 2023-04-12 22:42:17 +06:00
a2b497d0f9 update dependencies 2023-04-12 22:35:34 +06:00
c5974fb51c start 1.1.0 2023-04-12 22:33:22 +06:00
3240b63f21 Enlarge Java Heap space 2023-03-12 19:38:22 +06:00
fffafc4da7 Update libs.versions.toml 2023-03-12 19:34:08 +06:00
b1d5ce2135 Merge pull request #22 from InsanusMokrassar/1.0.0
1.0.0
2023-01-04 20:26:35 +06:00
0b8db9be35 Update CHANGELOG.md 2023-01-04 08:59:46 +06:00
5030ecc255 Update libs.versions.toml 2023-01-03 08:27:35 +06:00
b5669d2187 start 1.0.0 2023-01-03 08:23:30 +06:00
ed7ad35605 update publishing workflows 2022-12-05 15:53:37 +06:00
6d5ddafefc update publishing scripts 2022-12-05 15:51:11 +06:00
ee31c61677 Merge pull request #21 from InsanusMokrassar/0.5.4
0.5.4
2022-12-05 15:32:45 +06:00
1be14aa28e Update CHANGELOG.md 2022-12-05 15:32:27 +06:00
97b432c0b0 Update CHANGELOG.md 2022-12-05 08:06:39 +06:00
74a0ad8fd1 Update libs.versions.toml 2022-12-05 07:53:25 +06:00
502dd4d607 Update libs.versions.toml 2022-12-05 07:51:29 +06:00
079fbaa7f4 Update libs.versions.toml 2022-11-28 16:40:04 +06:00
99dac12a27 Update gradle.properties 2022-11-28 16:38:43 +06:00
b0cc6c11ea add platforms support badges 2022-11-28 13:28:13 +06:00
58161132dc Merge pull request #20 from InsanusMokrassar/0.5.3
0.5.3
2022-11-03 13:27:17 +06:00
7e45e5d421 Update CHANGELOG.md 2022-11-03 13:27:02 +06:00
e7956f6d31 Update README.md 2022-11-03 13:22:23 +06:00
9993fd5fdd Update libs.versions.toml 2022-11-03 13:11:51 +06:00
9e8665cdc9 Update gradle.properties 2022-11-03 13:09:32 +06:00
63d3cabc9c Merge pull request #19 from InsanusMokrassar/0.5.2
0.5.2
2022-09-12 15:46:27 +06:00
0b142c7ff9 add native platforms support 2022-09-12 15:44:59 +06:00
7a1d934dab start 0.5.2 2022-09-12 15:07:22 +06:00
b3720de8c7 Merge pull request #18 from InsanusMokrassar/0.5.1
0.5.1
2022-08-18 12:44:17 +06:00
669afe481d add defaultMessageFormatterWithErrorPrint 2022-08-13 20:19:21 +06:00
42db9da058 update gradle wrapper 2022-08-13 20:12:44 +06:00
72de26adac start 0.5.1 2022-08-13 20:12:19 +06:00
4b47a4e817 Merge pull request #17 from InsanusMokrassar/0.5.0
0.5.0
2022-08-04 17:19:33 +06:00
785ab59519 Update CHANGELOG.md 2022-08-04 16:57:38 +06:00
a4f2562690 Update libs.versions.toml 2022-08-04 16:56:30 +06:00
777ae44da5 Update gradle.properties 2022-08-04 16:54:14 +06:00
28d61a7b7c Merge pull request #16 from InsanusMokrassar/0.4.2
0.4.2
2022-07-31 19:26:54 +06:00
66c5451293 now tag in MessageFormatter is a nullable 2022-07-31 19:22:08 +06:00
77ca9ce25b MessageFormatter factory 2022-07-31 19:19:17 +06:00
194e52f521 addDefaultKSLog 2022-07-31 19:15:53 +06:00
34ea0bd91a isolate logging of KSLog'gers to avoid problems with parallel logs perform 2022-07-31 19:13:02 +06:00
3ff5d989b7 KSLog(SimpleKSLogCallback) 2022-07-31 19:09:01 +06:00
0e01534562 setDefaultKSLog and KSLog#plus(KSLog) 2022-07-31 19:06:57 +06:00
35e3d02837 start 0.4.2 2022-07-31 19:01:25 +06:00
b255406dba Update CHANGELOG.md 2022-07-30 17:13:55 +06:00
88fa4e3c09 Merge pull request #15 from InsanusMokrassar/0.4.1
0.4.1
2022-07-30 17:12:14 +06:00
4d9481f07b overloads resolution ambiguities issues fixes 2022-07-30 16:44:04 +06:00
54e448f5a0 start 0.4.1 2022-07-30 15:44:02 +06:00
8729acfff3 Update github_release.gradle 2022-07-30 15:20:00 +06:00
923add4550 Merge pull request #14 from InsanusMokrassar/0.4.0
0.4.0
2022-07-30 15:16:21 +06:00
29 changed files with 2254 additions and 70 deletions

View File

@@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-java@v1 - uses: actions/setup-java@v1
with: with:
java-version: 11 java-version: 17
- name: Build - name: Build
run: ./gradlew dokkaHtml run: ./gradlew dokkaHtml
- name: Publish KDocs - name: Publish KDocs

View File

@@ -7,10 +7,7 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-java@v1 - uses: actions/setup-java@v1
with: with:
java-version: 11 java-version: 17
- name: Fix android 32.0.0 dx
continue-on-error: true
run: cd /usr/local/lib/android/sdk/build-tools/32.0.0/ && mv d8 dx && cd lib && mv d8.jar dx.jar
- name: Rewrite version - name: Rewrite version
run: | run: |
branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`" branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`"
@@ -19,6 +16,11 @@ jobs:
mv gradle.properties.tmp gradle.properties mv gradle.properties.tmp gradle.properties
- name: Build - name: Build
run: ./gradlew build run: ./gradlew build
- name: Publish to Gitea
continue-on-error: true
run: ./gradlew publishAllPublicationsToGiteaRepository
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
- name: Publish - name: Publish
continue-on-error: true continue-on-error: true
run: ./gradlew --no-parallel publishAllPublicationsToGithubPackagesRepository run: ./gradlew --no-parallel publishAllPublicationsToGithubPackagesRepository

1
.gitignore vendored
View File

@@ -12,6 +12,5 @@ out/
secret.gradle secret.gradle
local.* local.*
local/ local/
kotlin-js-store/
publishing.sh publishing.sh

View File

@@ -1,5 +1,75 @@
# Changelog # Changelog
## 1.2.2
**wasm32 target has been removed**
**mingwX86 target has been removed**
* `Kotlin`: `1.9.20-RC`
## 1.2.1
* `Kotlin`: `1.9.10`
* Latest supported android sdk now is `34`
## 1.2.0
* `Kotlin`: `1.9.0`
## 1.1.2
* `Kotlin`: `1.8.22`
## 1.1.1
* Rollback `KSLog` with `String` arg factory to use `DefaultKSLog`
## 1.1.0
* `Kotlin`: `1.8.20`
* Standard factory `KSLog` with `String` arg now use `TagLogger`
## 1.0.0
* `Kotlin`: `1.8.0`
## 0.5.4
* `Kotlin`: `1.7.22`
## 0.5.3
* `Kotlin`: `1.7.20`
## 0.5.2
* Add support of next platform:
* Linux ARM x64
* Linux ARM x32 HFP
* Linux x64
* WASM x32
* MinGW x64
* MinGW x86
## 0.5.1
* New property `defaultMessageFormatterWithErrorPrint` for messages format with errors
## 0.5.0
* `Kotlin`: `1.7.10`
## 0.4.2
* Add `setDefaultKSLog` and `addDefaultKSLog`
* Add `plus` operation for two `KSLog` instances to call them both on each log performing
* Add `KSLog` factory for simple creation of `CallbackKSLog`
* Add `MessageFormatter` factory
## 0.4.1
* Fixes in resolution ambiguity for functions with messages
## 0.4.0 ## 0.4.0
**THIS UPDATE CONTAINS BREAKING CHANGES** **THIS UPDATE CONTAINS BREAKING CHANGES**

View File

@@ -1,18 +1,33 @@
# How to use # KSLog
It is simple and easy-to-use tool for logging on the most popular platforms in Kotlin Multiplatform:
![JVM](https://img.shields.io/badge/JVM-red?style=for-the-badge&logo=openjdk&logoColor=white) ![JVM](https://img.shields.io/badge/JVM-red?style=for-the-badge&logo=openjdk&logoColor=white)
![Android](https://img.shields.io/badge/Android-green?style=for-the-badge&logo=android&logoColor=white) ![Android](https://img.shields.io/badge/Android-green?style=for-the-badge&logo=android&logoColor=white)
![Js](https://img.shields.io/badge/JavaScript-323330?style=for-the-badge&logo=javascript&logoColor=F7DF1E) ![Js](https://img.shields.io/badge/JavaScript-323330?style=for-the-badge&logo=javascript&logoColor=F7DF1E)
![ARM x64](https://img.shields.io/badge/ARMx64-0091BD?style=for-the-badge&logo=arm&logoColor=F7DF1E)
![ARM x32](https://img.shields.io/badge/ARMx32-0091BD?style=for-the-badge&logo=arm&logoColor=F7DF1E)
![Linux x64](https://img.shields.io/badge/Linuxx64-FCC624?style=for-the-badge&logo=linux&logoColor=F7DF1E)
[![KDocs](https://img.shields.io/badge/KDocs-323330?style=for-the-badge&logo=Kotlin&logoColor=7F52FF)](https://insanusmokrassar.github.io/KSLog/) [![KDocs](https://img.shields.io/badge/KDocs-323330?style=for-the-badge&logo=Kotlin&logoColor=7F52FF)](https://insanusmokrassar.github.io/KSLog/)
[![Tutorials](https://img.shields.io/badge/Tutorials-0288D1?style=for-the-badge&logo=bookstack&logoColor=white)](https://bookstack.inmo.dev/books/kslog) [![Tutorials](https://img.shields.io/badge/Tutorials-0288D1?style=for-the-badge&logo=mkdocs&logoColor=white)](https://docs.inmo.dev/kslog/index.html)
It is simple logging tool which is using built-in tools for logging: By default, KSLog is using built-in tools for logging on each supported platform:
* `java.util.logging.Logger` for `JVM` * `java.util.logging.Logger` for `JVM`
* `android.util.Log` for `Android` * `android.util.Log` for `Android`
* `Console` for `JS` * `Console` for `JS`
But you always may create your logger and customize as you wish:
```kotlin
KSLog.default = KSLog { level: LogLevel, tag: String?, message: Any, throwable: Throwable? ->
// do your logging
}
```
**This library also supports native targets in experimental mode. By default all native targets will use simple printing in the console**
## How to use ## How to use
### Fast-travel ### Fast-travel
@@ -39,9 +54,11 @@ KSLog.l(LogLevel.INFO, "Some optional tag", IllegalArgumentException("So, that i
There are several important "terms" in context of this library: There are several important "terms" in context of this library:
* Default logger (available via `KSLog.default`) * Default logger (available via `KSLog.default` or simply `KSLog`)
* Local logger (can be created via `KSLog` functions and passed anywhere as `KSLog`) * Local logger (can be created via `KSLog` functions and passed anywhere as `KSLog`)
* Logging shortcuts like `KSLog.i`/`KSLog.info` * Logging shortcuts like `KSLog.i`/`KSLog.info`
* Built-in extension `Any.logger` which allow you to create logger binded to the default with the tag based on the class of receiver
* __Be careful with the receivers: if you will use some extension like `apply`, the receiver will be different with your class inside of that `apply`__
Every logging extension (like `KSLog.i`) have its analog with lazy inited message text and the same one with suffix `S` (like `KSLog.iS`) for the suspendable message calculation. Every logging extension (like `KSLog.i`) have its analog with lazy inited message text and the same one with suffix `S` (like `KSLog.iS`) for the suspendable message calculation.

View File

@@ -19,6 +19,7 @@ buildscript {
plugins { plugins {
alias(libs.plugins.kotlin.multiplatform) alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotlin.dokka) alias(libs.plugins.kotlin.dokka)
alias(libs.plugins.versions)
} }
apply plugin: "com.android.library" apply plugin: "com.android.library"
@@ -44,9 +45,23 @@ kotlin {
browser() browser()
nodejs() nodejs()
} }
android { androidTarget {
publishAllLibraryVariants() publishAllLibraryVariants()
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
} }
}
}
linuxArm64()
linuxArm32Hfp()
linuxX64()
wasm {
browser()
nodejs()
d8()
}
mingwX64()
sourceSets { sourceSets {
commonMain { commonMain {
@@ -54,6 +69,13 @@ kotlin {
implementation libs.kotlin implementation libs.kotlin
} }
} }
commonTest {
dependencies {
implementation libs.kotlin.test.common
implementation libs.kotlin.test.annotations.common
implementation libs.kotlin.test.junit
}
}
} }
} }

View File

@@ -26,8 +26,9 @@ android {
} }
} }
compileSdkVersion libs.versions.android.compileSdk.get().toInteger() compileSdk libs.versions.android.compileSdk.get().toInteger()
buildToolsVersion libs.versions.android.buildTools.get() buildToolsVersion = libs.versions.android.buildTools.get()
namespace "${group}.${project.name}"
defaultConfig { defaultConfig {
minSdkVersion libs.versions.android.minSdk.get().toInteger() minSdkVersion libs.versions.android.minSdk.get().toInteger()
@@ -55,10 +56,6 @@ android {
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
sourceSets { sourceSets {
String sep = File.separator String sep = File.separator
main.java.srcDirs += "src${sep}main${sep}kotlin" main.java.srcDirs += "src${sep}main${sep}kotlin"

View File

@@ -21,7 +21,7 @@ if (new File(projectDir, "secret.gradle").exists()) {
owner "InsanusMokrassar" owner "InsanusMokrassar"
repo "KSLog" repo "KSLog"
tagName "${project.version}" tagName "v${project.version}"
releaseName "${project.version}" releaseName "${project.version}"
targetCommitish "${project.version}" targetCommitish "${project.version}"

View File

@@ -5,9 +5,10 @@ kotlin.incremental=true
kotlin.incremental.js=true kotlin.incremental.js=true
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
org.gradle.jvmargs=-Xmx512m
# Project data # Project data
group=dev.inmo group=dev.inmo
version=0.4.0 version=1.2.2
android_code_version=10 android_code_version=24

View File

@@ -1,16 +1,20 @@
[versions] [versions]
kotlin = "1.6.21" kotlin = "1.9.20-RC"
kotlin-gradle-plugin = "7.0.4" kotlin-gradle-plugin = "8.1.2"
dexcount = "3.1.0" versions = "0.48.0"
dokka = "1.9.10"
dexcount = "4.0.0"
junit_version = "4.12" junit_version = "4.12"
test_ext_junit_version = "1.1.2" test_ext_junit_version = "1.1.5"
espresso_core = "3.3.0" espresso_core = "3.5.1"
android-minSdk = "21" android-minSdk = "21"
android-compileSdk = "32" android-compileSdk = "34"
android-buildTools = "32.0.0" android-buildTools = "34.0.0"
github-release = "2.4.1" github-release = "2.4.1"
@@ -29,10 +33,12 @@ android-test-espresso-core = { module = "androidx.test.espresso:espresso-core",
android-tools-build = { module = "com.android.tools.build:gradle", version.ref = "kotlin-gradle-plugin" } android-tools-build = { module = "com.android.tools.build:gradle", version.ref = "kotlin-gradle-plugin" }
android-dexcount = { module = "com.getkeepsafe.dexcount:dexcount-gradle-plugin", version.ref = "dexcount" } android-dexcount = { module = "com.getkeepsafe.dexcount:dexcount-gradle-plugin", version.ref = "dexcount" }
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "kotlin" } kotlin-dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
github-release = { module = "com.github.breadmoirai:github-release", version.ref = "github-release" } github-release = { module = "com.github.breadmoirai:github-release", version.ref = "github-release" }
[plugins] [plugins]
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-dokka = { id = "org.jetbrains.dokka", version.ref = "kotlin" } kotlin-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
versions = { id = "com.github.ben-manes.versions", version.ref = "versions" }

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

1921
kotlin-js-store/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
task javadocsJar(type: Jar) { task javadocsJar(type: Jar) {
classifier = 'javadoc' archiveClassifier = 'javadoc'
} }
publishing { publishing {
@@ -49,20 +49,40 @@ publishing {
maven { maven {
name = "GithubPackages" name = "GithubPackages"
url = uri("https://maven.pkg.github.com/InsanusMokrassar/KSLog") url = uri("https://maven.pkg.github.com/InsanusMokrassar/KSLog")
credentials { credentials {
username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER') username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER')
password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD') password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD')
} }
}
}
if (project.hasProperty('GITEA_TOKEN') || System.getenv('GITEA_TOKEN') != null) {
maven {
name = "Gitea"
url = uri("https://git.inmo.dev/api/packages/InsanusMokrassar/maven")
credentials(HttpHeaderCredentials) {
name = "Authorization"
value = project.hasProperty('GITEA_TOKEN') ? project.property('GITEA_TOKEN') : System.getenv('GITEA_TOKEN')
}
authentication {
header(HttpHeaderAuthentication)
}
} }
} }
if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) { if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) {
maven { maven {
name = "sonatype" name = "sonatype"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials { credentials {
username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER') username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD') password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
} }
} }
} }
} }

View File

@@ -1 +1 @@
{"licenses":[{"id":"MIT","title":"MIT License","url":"https://opensource.org/licenses/MIT"}],"mavenConfig":{"name":"${project.name}","description":"Simple logging library for kotlin","url":"https://github.com/InsanusMokrassar/KSLog","vcsUrl":"https://github.com/InsanusMokrassar/KSLog.git","developers":[{"id":"Akkihi","name":"Akkihi","eMail":"akkihiguy@gmail.com"},{"id":"InsanusMokrassar","name":"InsanusMokrassar","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/KSLog"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"}}} {"licenses":[{"id":"MIT","title":"MIT License","url":"https://opensource.org/licenses/MIT"}],"mavenConfig":{"name":"${project.name}","description":"Simple logging library for kotlin","url":"https://github.com/InsanusMokrassar/KSLog","vcsUrl":"https://github.com/InsanusMokrassar/KSLog.git","developers":[{"id":"Akkihi","name":"Akkihi","eMail":"akkihiguy@gmail.com"},{"id":"InsanusMokrassar","name":"InsanusMokrassar","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/KSLog"},{"name":"Gitea","url":"https://git.inmo.dev/api/packages/InsanusMokrassar/maven","credsType":{"type":"dev.inmo.kmppscriptbuilder.core.models.MavenPublishingRepository.CredentialsType.HttpHeaderCredentials","headerName":"Authorization","headerValueProperty":"GITEA_TOKEN"}},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"}}}

6
renovate.json Normal file
View File

@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
]
}

View File

@@ -1,3 +1 @@
rootProject.name = 'kslog' rootProject.name = 'kslog'
enableFeaturePreview("VERSION_CATALOGS")

View File

@@ -0,0 +1 @@
<manifest/>

View File

@@ -7,3 +7,7 @@ class CallbackKSLog(
) : KSLog { ) : KSLog {
override fun performLog(level: LogLevel, tag: String?, message: Any, throwable: Throwable?) = performLogCallback(level, tag, message, throwable) override fun performLog(level: LogLevel, tag: String?, message: Any, throwable: Throwable?) = performLogCallback(level, tag, message, throwable)
} }
fun KSLog(
performLogCallback: SimpleKSLogCallback
) = CallbackKSLog(performLogCallback)

View File

@@ -3,113 +3,183 @@
package dev.inmo.kslog.common package dev.inmo.kslog.common
inline fun KSLog.log(level: LogLevel, tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = performLog(level, tag, e, messageBuilder) inline fun KSLog.log(level: LogLevel, tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = performLog(level, tag, e, messageBuilder)
inline fun KSLog.log(level: LogLevel, tag: String, noinline messageBuilder: () -> Any) = performLog(level, tag, null, messageBuilder)
suspend inline fun KSLog.logS(level: LogLevel, tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = performLogS(level, tag, e, messageBuilder) suspend inline fun KSLog.logS(level: LogLevel, tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = performLogS(level, tag, e, messageBuilder)
suspend inline fun KSLog.logS(level: LogLevel, tag: String, noinline messageBuilder: suspend () -> Any) = performLogS(level, tag, null, messageBuilder)
inline fun KSLog.log(level: LogLevel, e: Throwable? = null, noinline messageBuilder: () -> Any) = performLog(level, null, e, messageBuilder) inline fun KSLog.log(level: LogLevel, e: Throwable? = null, noinline messageBuilder: () -> Any) = performLog(level, null, e, messageBuilder)
suspend inline fun KSLog.logS(level: LogLevel, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = performLogS(level, null, e, messageBuilder) suspend inline fun KSLog.logS(level: LogLevel, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = performLogS(level, null, e, messageBuilder)
inline fun KSLog.log(level: LogLevel, message: Any, e: Throwable? = null) = performLog(level, message, e) inline fun KSLog.log(level: LogLevel, message: Any, e: Throwable?) = performLog(level, message, e)
inline fun KSLog.log(level: LogLevel, tag: String, message: Any, e: Throwable? = null) = performLog(level, tag, message, e) inline fun KSLog.log(level: LogLevel, message: String, e: Throwable) = log(level, message as Any, e)
inline fun KSLog.log(level: LogLevel, message: Any) = performLog(level, message, null)
inline fun KSLog.log(level: LogLevel, tag: String, message: Any, e: Throwable?) = performLog(level, tag, message, e)
inline fun KSLog.log(level: LogLevel, tag: String, message: Any) = performLog(level, tag, message, null)
inline fun KSLog.debug(e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.DEBUG, null, e, messageBuilder) inline fun KSLog.debug(e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.DEBUG, null, e, messageBuilder)
inline fun KSLog.debug(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.DEBUG, tag, e, messageBuilder) inline fun KSLog.debug(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.DEBUG, tag, e, messageBuilder)
inline fun KSLog.debug(tag: String, noinline messageBuilder: () -> Any) = debug(tag, null, messageBuilder)
suspend inline fun KSLog.debugS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.DEBUG, null, e, messageBuilder) suspend inline fun KSLog.debugS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.DEBUG, null, e, messageBuilder)
suspend inline fun KSLog.debugS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.DEBUG, tag, e, messageBuilder) suspend inline fun KSLog.debugS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.DEBUG, tag, e, messageBuilder)
inline fun KSLog.debug(message: Any, e: Throwable? = null) = log(LogLevel.DEBUG, message, e) suspend inline fun KSLog.debugS(tag: String, noinline messageBuilder: suspend () -> Any) = debugS(tag, null, messageBuilder)
inline fun KSLog.debug(tag: String, message: Any, e: Throwable? = null) = log(LogLevel.DEBUG, tag, message, e) inline fun KSLog.debug(message: Any, e: Throwable?) = log(LogLevel.DEBUG, message, e)
inline fun KSLog.debug(message: String, e: Throwable) = debug(message as Any, e)
inline fun KSLog.debug(message: Any) = debug(message, null)
inline fun KSLog.debug(tag: String, message: Any, e: Throwable?) = log(LogLevel.DEBUG, tag, message, e)
inline fun KSLog.debug(tag: String, message: Any) = debug(tag, message, null)
inline fun KSLog.verbose(e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.VERBOSE, null, e, messageBuilder) inline fun KSLog.verbose(e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.VERBOSE, null, e, messageBuilder)
inline fun KSLog.verbose(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.VERBOSE, tag, e, messageBuilder) inline fun KSLog.verbose(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.VERBOSE, tag, e, messageBuilder)
inline fun KSLog.verbose(tag: String, noinline messageBuilder: () -> Any) = verbose(tag, null, messageBuilder)
suspend inline fun KSLog.verboseS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.VERBOSE, null, e, messageBuilder) suspend inline fun KSLog.verboseS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.VERBOSE, null, e, messageBuilder)
suspend inline fun KSLog.verboseS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.VERBOSE, tag, e, messageBuilder) suspend inline fun KSLog.verboseS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.VERBOSE, tag, e, messageBuilder)
inline fun KSLog.verbose(message: Any, e: Throwable? = null) = log(LogLevel.VERBOSE, message, e) suspend inline fun KSLog.verboseS(tag: String, noinline messageBuilder: suspend () -> Any) = verboseS(tag, null, messageBuilder)
inline fun KSLog.verbose(tag: String, message: Any, e: Throwable? = null) = log(LogLevel.VERBOSE, tag, message, e) inline fun KSLog.verbose(message: Any, e: Throwable?) = log(LogLevel.VERBOSE, message, e)
inline fun KSLog.verbose(message: String, e: Throwable) = verbose(message as Any, e)
inline fun KSLog.verbose(message: Any) = verbose(message, null)
inline fun KSLog.verbose(tag: String, message: Any, e: Throwable?) = log(LogLevel.VERBOSE, tag, message, e)
inline fun KSLog.verbose(tag: String, message: Any) = verbose(tag, message, null)
inline fun KSLog.info(e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.INFO, null, e, messageBuilder) inline fun KSLog.info(e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.INFO, null, e, messageBuilder)
inline fun KSLog.info(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.INFO, tag, e, messageBuilder) inline fun KSLog.info(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.INFO, tag, e, messageBuilder)
inline fun KSLog.info(tag: String, noinline messageBuilder: () -> Any) = info(tag, null, messageBuilder)
suspend inline fun KSLog.infoS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.INFO, null, e, messageBuilder) suspend inline fun KSLog.infoS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.INFO, null, e, messageBuilder)
suspend inline fun KSLog.infoS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.INFO, tag, e, messageBuilder) suspend inline fun KSLog.infoS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.INFO, tag, e, messageBuilder)
inline fun KSLog.info(message: Any, e: Throwable? = null) = log(LogLevel.INFO, message, e) suspend inline fun KSLog.infoS(tag: String, noinline messageBuilder: suspend () -> Any) = infoS(tag, null, messageBuilder)
inline fun KSLog.info(tag: String, message: Any, e: Throwable? = null) = log(LogLevel.INFO, tag, message, e) inline fun KSLog.info(message: Any, e: Throwable?) = log(LogLevel.INFO, message, e)
inline fun KSLog.info(message: String, e: Throwable) = info(message as Any, e)
inline fun KSLog.info(message: Any) = info(message, null)
inline fun KSLog.info(tag: String, message: Any, e: Throwable?) = log(LogLevel.INFO, tag, message, e)
inline fun KSLog.info(tag: String, message: Any) = info(tag, message, null)
inline fun KSLog.warning(e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.WARNING, null, e, messageBuilder) inline fun KSLog.warning(e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.WARNING, null, e, messageBuilder)
inline fun KSLog.warning(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.WARNING, tag, e, messageBuilder) inline fun KSLog.warning(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.WARNING, tag, e, messageBuilder)
inline fun KSLog.warning(tag: String, noinline messageBuilder: () -> Any) = warning(tag, null, messageBuilder)
suspend inline fun KSLog.warningS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.WARNING, null, e, messageBuilder) suspend inline fun KSLog.warningS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.WARNING, null, e, messageBuilder)
suspend inline fun KSLog.warningS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.WARNING, tag, e, messageBuilder) suspend inline fun KSLog.warningS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.WARNING, tag, e, messageBuilder)
inline fun KSLog.warning(message: Any, e: Throwable? = null) = log(LogLevel.WARNING, message, e) suspend inline fun KSLog.warningS(tag: String, noinline messageBuilder: suspend () -> Any) = warningS(tag, null, messageBuilder)
inline fun KSLog.warning(tag: String, message: Any, e: Throwable? = null) = log(LogLevel.WARNING, tag, message, e) inline fun KSLog.warning(message: Any, e: Throwable?) = log(LogLevel.WARNING, message, e)
inline fun KSLog.warning(message: String, e: Throwable) = warning(message as Any, e)
inline fun KSLog.warning(message: Any) = warning(message, null)
inline fun KSLog.warning(tag: String, message: Any, e: Throwable?) = log(LogLevel.WARNING, tag, message, e)
inline fun KSLog.warning(tag: String, message: Any) = warning(tag, message, null)
inline fun KSLog.error(e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.ERROR, null, e, messageBuilder) inline fun KSLog.error(e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.ERROR, null, e, messageBuilder)
inline fun KSLog.error(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.ERROR, tag, e, messageBuilder) inline fun KSLog.error(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.ERROR, tag, e, messageBuilder)
inline fun KSLog.error(tag: String, noinline messageBuilder: () -> Any) = error(tag, null, messageBuilder)
suspend inline fun KSLog.errorS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.ERROR, null, e, messageBuilder) suspend inline fun KSLog.errorS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.ERROR, null, e, messageBuilder)
suspend inline fun KSLog.errorS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.ERROR, tag, e, messageBuilder) suspend inline fun KSLog.errorS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.ERROR, tag, e, messageBuilder)
inline fun KSLog.error(message: Any, e: Throwable? = null) = log(LogLevel.ERROR, message, e) suspend inline fun KSLog.errorS(tag: String, noinline messageBuilder: suspend () -> Any) = errorS(tag, null, messageBuilder)
inline fun KSLog.error(tag: String, message: Any, e: Throwable? = null) = log(LogLevel.ERROR, tag, message, e) inline fun KSLog.error(message: Any, e: Throwable?) = log(LogLevel.ERROR, message, e)
inline fun KSLog.error(message: String, e: Throwable) = error(message as Any, e)
inline fun KSLog.error(message: Any) = error(message, null)
inline fun KSLog.error(tag: String, message: Any, e: Throwable?) = log(LogLevel.ERROR, tag, message, e)
inline fun KSLog.error(tag: String, message: Any) = error(tag, message, null)
inline fun KSLog.assert(e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.ASSERT, null, e, messageBuilder) inline fun KSLog.assert(e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.ASSERT, null, e, messageBuilder)
inline fun KSLog.assert(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.ASSERT, tag, e, messageBuilder) inline fun KSLog.assert(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(LogLevel.ASSERT, tag, e, messageBuilder)
inline fun KSLog.assert(tag: String, noinline messageBuilder: () -> Any) = assert(tag, null, messageBuilder)
suspend inline fun KSLog.assertS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.ASSERT, null, e, messageBuilder) suspend inline fun KSLog.assertS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.ASSERT, null, e, messageBuilder)
suspend inline fun KSLog.assertS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.ASSERT, tag, e, messageBuilder) suspend inline fun KSLog.assertS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(LogLevel.ASSERT, tag, e, messageBuilder)
inline fun KSLog.assert(message: Any, e: Throwable? = null) = log(LogLevel.ASSERT, message, e) suspend inline fun KSLog.assertS(tag: String, noinline messageBuilder: suspend () -> Any) = assertS(tag, null, messageBuilder)
inline fun KSLog.assert(tag: String, message: Any, e: Throwable? = null) = log(LogLevel.ASSERT, tag, message, e) inline fun KSLog.assert(message: Any, e: Throwable?) = log(LogLevel.ASSERT, message, e)
inline fun KSLog.assert(message: String, e: Throwable) = assert(message as Any, e)
inline fun KSLog.assert(message: Any) = assert(message, null)
inline fun KSLog.assert(tag: String, message: Any, e: Throwable?) = log(LogLevel.ASSERT, tag, message, e)
inline fun KSLog.assert(tag: String, message: Any) = assert(tag, message, null)
// ----- Short names // ----- Short names
inline fun KSLog.l(level: LogLevel, tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(level, tag, e, messageBuilder) inline fun KSLog.l(level: LogLevel, tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(level, tag, e, messageBuilder)
inline fun KSLog.l(level: LogLevel, tag: String, noinline messageBuilder: () -> Any) = l(level, tag, null, messageBuilder)
inline fun KSLog.l(level: LogLevel, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(level, e, messageBuilder) inline fun KSLog.l(level: LogLevel, e: Throwable? = null, noinline messageBuilder: () -> Any) = log(level, e, messageBuilder)
suspend inline fun KSLog.lS(level: LogLevel, tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(level, tag, e, messageBuilder) suspend inline fun KSLog.lS(level: LogLevel, tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(level, tag, e, messageBuilder)
suspend inline fun KSLog.lS(level: LogLevel, tag: String, noinline messageBuilder: suspend () -> Any) = lS(level, tag, null, messageBuilder)
suspend inline fun KSLog.lS(level: LogLevel, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(level, e, messageBuilder) suspend inline fun KSLog.lS(level: LogLevel, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = logS(level, e, messageBuilder)
inline fun KSLog.l(level: LogLevel, message: Any, e: Throwable? = null) = log(level, message, e) inline fun KSLog.l(level: LogLevel, message: Any, e: Throwable?) = log(level, message, e)
inline fun KSLog.l(level: LogLevel, tag: String, message: Any, e: Throwable? = null) = log(level, tag, message, e) inline fun KSLog.l(level: LogLevel, message: String, e: Throwable) = l(level, message as Any, e)
inline fun KSLog.l(level: LogLevel, message: Any) = log(level, message, null)
inline fun KSLog.l(level: LogLevel, tag: String, message: Any, e: Throwable?) = log(level, tag, message, e)
inline fun KSLog.l(level: LogLevel, tag: String, message: Any) = log(level, tag, message, null)
inline fun KSLog.d(e: Throwable? = null, noinline messageBuilder: () -> Any) = debug(e, messageBuilder) inline fun KSLog.d(e: Throwable? = null, noinline messageBuilder: () -> Any) = debug(e, messageBuilder)
inline fun KSLog.d(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = debug(tag, e, messageBuilder) inline fun KSLog.d(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = debug(tag, e, messageBuilder)
inline fun KSLog.d(tag: String, noinline messageBuilder: () -> Any) = d(tag, null, messageBuilder)
suspend inline fun KSLog.dS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = debugS(e, messageBuilder) suspend inline fun KSLog.dS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = debugS(e, messageBuilder)
suspend inline fun KSLog.dS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = debugS(tag, e, messageBuilder) suspend inline fun KSLog.dS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = debugS(tag, e, messageBuilder)
inline fun KSLog.d(message: Any, e: Throwable? = null) = debug(message, e) suspend inline fun KSLog.dS(tag: String, noinline messageBuilder: suspend () -> Any) = dS(tag, null, messageBuilder)
inline fun KSLog.d(tag: String, message: Any, e: Throwable? = null) = debug(tag, message, e) inline fun KSLog.d(message: Any, e: Throwable?) = debug(message, e)
inline fun KSLog.d(message: String, e: Throwable) = d(message as Any, e)
inline fun KSLog.d(message: Any) = d(message, null)
inline fun KSLog.d(tag: String, message: Any, e: Throwable?) = debug(tag, message, e)
inline fun KSLog.d(tag: String, message: Any) = d(tag, message, null)
inline fun KSLog.v(e: Throwable? = null, noinline messageBuilder: () -> Any) = verbose(e, messageBuilder) inline fun KSLog.v(e: Throwable? = null, noinline messageBuilder: () -> Any) = verbose(e, messageBuilder)
inline fun KSLog.v(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = verbose(tag, e, messageBuilder) inline fun KSLog.v(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = verbose(tag, e, messageBuilder)
inline fun KSLog.v(tag: String, noinline messageBuilder: () -> Any) = v(tag, null, messageBuilder)
suspend inline fun KSLog.vS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = verboseS(e, messageBuilder) suspend inline fun KSLog.vS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = verboseS(e, messageBuilder)
suspend inline fun KSLog.vS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = verboseS(tag, e, messageBuilder) suspend inline fun KSLog.vS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = verboseS(tag, e, messageBuilder)
inline fun KSLog.v(message: Any, e: Throwable? = null) = verbose(message, e) suspend inline fun KSLog.vS(tag: String, noinline messageBuilder: suspend () -> Any) = vS(tag, null, messageBuilder)
inline fun KSLog.v(tag: String, message: Any, e: Throwable? = null) = verbose(tag, message, e) inline fun KSLog.v(message: Any, e: Throwable?) = verbose(message, e)
inline fun KSLog.v(message: String, e: Throwable) = v(message as Any, e)
inline fun KSLog.v(message: Any) = v(message, null)
inline fun KSLog.v(tag: String, message: Any, e: Throwable?) = verbose(tag, message, e)
inline fun KSLog.v(tag: String, message: Any) = v(tag, message, null)
inline fun KSLog.i(e: Throwable? = null, noinline messageBuilder: () -> Any) = info(e, messageBuilder) inline fun KSLog.i(e: Throwable? = null, noinline messageBuilder: () -> Any) = info(e, messageBuilder)
inline fun KSLog.i(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = info(tag, e, messageBuilder) inline fun KSLog.i(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = info(tag, e, messageBuilder)
inline fun KSLog.i(tag: String, noinline messageBuilder: () -> Any) = i(tag, null, messageBuilder)
suspend inline fun KSLog.iS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = infoS(e, messageBuilder) suspend inline fun KSLog.iS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = infoS(e, messageBuilder)
suspend inline fun KSLog.iS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = infoS(tag, e, messageBuilder) suspend inline fun KSLog.iS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = infoS(tag, e, messageBuilder)
inline fun KSLog.i(message: Any, e: Throwable? = null) = info(message, e) suspend inline fun KSLog.iS(tag: String, noinline messageBuilder: suspend () -> Any) = iS(tag, null, messageBuilder)
inline fun KSLog.i(tag: String, message: Any, e: Throwable? = null) = info(tag, message, e) inline fun KSLog.i(message: Any, e: Throwable?) = info(message, e)
inline fun KSLog.i(message: String, e: Throwable) = i(message as Any, e)
inline fun KSLog.i(message: Any) = i(message, null)
inline fun KSLog.i(tag: String, message: Any, e: Throwable?) = info(tag, message, e)
inline fun KSLog.i(tag: String, message: Any) = i(tag, message, null)
inline fun KSLog.w(e: Throwable? = null, noinline messageBuilder: () -> Any) = warning(e, messageBuilder) inline fun KSLog.w(e: Throwable? = null, noinline messageBuilder: () -> Any) = warning(e, messageBuilder)
inline fun KSLog.w(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = warning(tag, e, messageBuilder) inline fun KSLog.w(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = warning(tag, e, messageBuilder)
inline fun KSLog.w(tag: String, noinline messageBuilder: () -> Any) = w(tag, null, messageBuilder)
suspend inline fun KSLog.wS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = warningS(e, messageBuilder) suspend inline fun KSLog.wS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = warningS(e, messageBuilder)
suspend inline fun KSLog.wS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = warningS(tag, e, messageBuilder) suspend inline fun KSLog.wS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = warningS(tag, e, messageBuilder)
inline fun KSLog.w(message: Any, e: Throwable? = null) = warning(message, e) suspend inline fun KSLog.wS(tag: String, noinline messageBuilder: suspend () -> Any) = wS(tag, null, messageBuilder)
inline fun KSLog.w(tag: String, message: Any, e: Throwable? = null) = warning(tag, message, e) inline fun KSLog.w(message: Any, e: Throwable?) = warning(message, e)
inline fun KSLog.w(message: String, e: Throwable) = w(message as Any, e)
inline fun KSLog.w(message: Any) = w(message, null)
inline fun KSLog.w(tag: String, message: Any, e: Throwable?) = warning(tag, message, e)
inline fun KSLog.w(tag: String, message: Any) = w(tag, message, null)
inline fun KSLog.e(e: Throwable? = null, noinline messageBuilder: () -> Any) = error(e, messageBuilder) inline fun KSLog.e(e: Throwable? = null, noinline messageBuilder: () -> Any) = error(e, messageBuilder)
inline fun KSLog.e(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = error(tag, e, messageBuilder) inline fun KSLog.e(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = error(tag, e, messageBuilder)
inline fun KSLog.e(tag: String, noinline messageBuilder: () -> Any) = e(tag, null, messageBuilder)
suspend inline fun KSLog.eS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = errorS(e, messageBuilder) suspend inline fun KSLog.eS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = errorS(e, messageBuilder)
suspend inline fun KSLog.eS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = errorS(tag, e, messageBuilder) suspend inline fun KSLog.eS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = errorS(tag, e, messageBuilder)
inline fun KSLog.e(message: Any, e: Throwable? = null) = error(message, e) suspend inline fun KSLog.eS(tag: String, noinline messageBuilder: suspend () -> Any) = eS(tag, null, messageBuilder)
inline fun KSLog.e(tag: String, message: Any, e: Throwable? = null) = error(tag, message, e) inline fun KSLog.e(message: Any, e: Throwable?) = error(message, e)
inline fun KSLog.e(message: String, e: Throwable) = e(message as Any, e)
inline fun KSLog.e(message: Any) = e(message, null)
inline fun KSLog.e(tag: String, message: Any, e: Throwable?) = error(tag, message, e)
inline fun KSLog.e(tag: String, message: Any) = e(tag, message, null)
inline fun KSLog.wtf(e: Throwable? = null, noinline messageBuilder: () -> Any) = assert(e, messageBuilder) inline fun KSLog.wtf(e: Throwable? = null, noinline messageBuilder: () -> Any) = assert(e, messageBuilder)
inline fun KSLog.wtf(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = assert(tag, e, messageBuilder) inline fun KSLog.wtf(tag: String?, e: Throwable? = null, noinline messageBuilder: () -> Any) = assert(tag, e, messageBuilder)
inline fun KSLog.wtf(tag: String, noinline messageBuilder: () -> Any) = wtf(tag, null, messageBuilder)
suspend inline fun KSLog.wtfS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = assertS(e, messageBuilder) suspend inline fun KSLog.wtfS(e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = assertS(e, messageBuilder)
suspend inline fun KSLog.wtfS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = assertS(tag, e, messageBuilder) suspend inline fun KSLog.wtfS(tag: String?, e: Throwable? = null, noinline messageBuilder: suspend () -> Any) = assertS(tag, e, messageBuilder)
inline fun KSLog.wtf(message: Any, e: Throwable? = null) = assert(message, e) suspend inline fun KSLog.wtfS(tag: String, noinline messageBuilder: suspend () -> Any) = wtfS(tag, null, messageBuilder)
inline fun KSLog.wtf(tag: String, message: Any, e: Throwable? = null) = assert(tag, message, e) inline fun KSLog.wtf(message: Any, e: Throwable?) = assert(message, e)
inline fun KSLog.wtf(message: String, e: Throwable) = wtf(message as Any, e)
inline fun KSLog.wtf(message: Any) = wtf(message, null)
inline fun KSLog.wtf(tag: String, message: Any, e: Throwable?) = assert(tag, message, e)
inline fun KSLog.wtf(tag: String, message: Any) = wtf(tag, message, null)

View File

@@ -1,6 +1,7 @@
package dev.inmo.kslog.common package dev.inmo.kslog.common
import dev.inmo.kslog.common.filter.filtered import dev.inmo.kslog.common.filter.filtered
import dev.inmo.kslog.common.utils.plus
enum class LogLevel { enum class LogLevel {
@@ -31,6 +32,10 @@ interface KSLog {
companion object : KSLog { companion object : KSLog {
private var defaultLogger: KSLog? = null private var defaultLogger: KSLog? = null
/**
* Default logger used in case you are trying to use [KSLog] as a receiver for extensions like [info]
*/
var default: KSLog var default: KSLog
get() { get() {
return defaultLogger ?: KSLog("app").also { return defaultLogger ?: KSLog("app").also {
@@ -61,10 +66,17 @@ interface KSLog {
operator fun KSLog.invoke(performLogCallback: (level: LogLevel, tag: String?, message: Any, throwable: Throwable?) -> Unit) = CallbackKSLog(performLogCallback) operator fun KSLog.invoke(performLogCallback: (level: LogLevel, tag: String?, message: Any, throwable: Throwable?) -> Unit) = CallbackKSLog(performLogCallback)
internal expect val defaultLogging: (level: LogLevel, tag: String, message: Any, throwable: Throwable?) -> Unit internal expect val defaultLogging: (level: LogLevel, tag: String, message: Any, throwable: Throwable?) -> Unit
internal val printlnLogging: (level: LogLevel, tag: String, message: Any, throwable: Throwable?) -> Unit = { l, t, m, e ->
println(defaultMessageFormatter(l, t, m, e))
}
fun KSLog( fun KSLog(
defaultTag: String, defaultTag: String,
messageFormatter: MessageFormatter = defaultMessageFormatter ): KSLog = DefaultKSLog(defaultTag)
fun KSLog(
defaultTag: String,
messageFormatter: MessageFormatter
): KSLog = DefaultKSLog( ): KSLog = DefaultKSLog(
defaultTag, defaultTag,
messageFormatter messageFormatter
@@ -75,11 +87,10 @@ fun KSLog(
defaultTag: String, defaultTag: String,
filter: MessageFilter, filter: MessageFilter,
messageFormatter: MessageFormatter = defaultMessageFormatter messageFormatter: MessageFormatter = defaultMessageFormatter
): KSLog = DefaultKSLog( ): KSLog = KSLog (
defaultTag, defaultTag,
filter,
messageFormatter messageFormatter
) ).filtered(filter)
fun KSLog( fun KSLog(
defaultTag: String, defaultTag: String,
@@ -110,3 +121,6 @@ fun KSLog(
).filtered { l, _, _ -> ).filtered { l, _, _ ->
minLoggingLevel.ordinal <= l.ordinal minLoggingLevel.ordinal <= l.ordinal
} }
fun setDefaultKSLog(newDefault: KSLog) { KSLog.default = newDefault }
fun addDefaultKSLog(newDefault: KSLog) { KSLog.default = KSLog.default + newDefault }

View File

@@ -1,6 +1,8 @@
package dev.inmo.kslog.common package dev.inmo.kslog.common
typealias MessageFormatter = (l: LogLevel, t: String, m: Any, Throwable?) -> String typealias MessageFormatter = (l: LogLevel, t: String?, m: Any, Throwable?) -> String
@Suppress("NOTHING_TO_INLINE")
inline fun MessageFormatter(noinline formatter: MessageFormatter) = formatter
typealias MessageFilter = (l: LogLevel, t: String?, Throwable?) -> Boolean typealias MessageFilter = (l: LogLevel, t: String?, Throwable?) -> Boolean
val defaultMessageFormatter: MessageFormatter = { l, t, m, _ -> "[$l] $t - $m" } val defaultMessageFormatter: MessageFormatter = { l, t, m, _ -> "[$l] ${t ?.let { "$it " } ?: ""}- $m" }
val defaultMessageFormatterWithErrorPrint: MessageFormatter = { l, t, m, e -> "[$l] ${t ?.let { "$it " } ?: ""}- $m${e ?.let { ": ${it.stackTraceToString()}" } ?: ""}" }

View File

@@ -0,0 +1,15 @@
package dev.inmo.kslog.common.utils
import dev.inmo.kslog.common.CallbackKSLog
import dev.inmo.kslog.common.KSLog
infix operator fun KSLog.plus(other: KSLog) = CallbackKSLog { l, t, m, e ->
val resultOfFirst = runCatching {
this@plus.performLog(l, t, m, e)
}
val resultOfSecond = runCatching {
other.performLog(l, t, m, e)
}
resultOfFirst.onFailure { throw it }
resultOfSecond.onFailure { throw it }
}

View File

@@ -0,0 +1,4 @@
package dev.inmo.kslog.common
internal actual val defaultLogging: (level: LogLevel, tag: String, message: Any, throwable: Throwable?) -> Unit
get() = printlnLogging

View File

@@ -0,0 +1,4 @@
package dev.inmo.kslog.common
internal actual val defaultLogging: (level: LogLevel, tag: String, message: Any, throwable: Throwable?) -> Unit
get() = printlnLogging

View File

@@ -0,0 +1,4 @@
package dev.inmo.kslog.common
internal actual val defaultLogging: (level: LogLevel, tag: String, message: Any, throwable: Throwable?) -> Unit
get() = printlnLogging

View File

@@ -1 +0,0 @@
<manifest package="dev.inmo.kslog"/>

View File

@@ -0,0 +1,4 @@
package dev.inmo.kslog.common
internal actual val defaultLogging: (level: LogLevel, tag: String, message: Any, throwable: Throwable?) -> Unit
get() = printlnLogging

View File

@@ -0,0 +1,4 @@
package dev.inmo.kslog.common
internal actual val defaultLogging: (level: LogLevel, tag: String, message: Any, throwable: Throwable?) -> Unit
get() = printlnLogging