Skip to content
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

4.x changes #269

Merged
merged 49 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
c40ec11
Add Level to common
oshai Jan 22, 2023
193f634
Add Marker to common
oshai Jan 22, 2023
0f89354
Move MarkerFactory to common
oshai Jan 23, 2023
aecab84
add fl4j methods to logger
oshai Jan 23, 2023
e06e0a9
more fixes
oshai Jan 23, 2023
60d3ede
rename package mu to mu.two
oshai Jan 29, 2023
7ef56d1
rename package mu to mu.two - cont
oshai Jan 29, 2023
8c41509
fix formatting
oshai Jan 29, 2023
eea9552
fix tests
oshai Jan 29, 2023
de118b6
fix tests
oshai Jan 29, 2023
bdcf879
update kotlin to 1.8.0
oshai Jan 29, 2023
6c1a399
change slf4j dep for compile only
oshai Jan 29, 2023
5f853bd
move methods to Slf4jExtensions.kt
oshai Jan 29, 2023
e39146e
fix formatting
oshai Jan 29, 2023
db615e3
fix compilation
oshai Jan 29, 2023
ddc242d
add jul
oshai Jan 29, 2023
811707c
add jul impl
oshai Jan 31, 2023
102c48c
add jul test
oshai Jan 31, 2023
8c2b16c
add jul test
oshai Jan 31, 2023
36d1372
add jul test
oshai Jan 31, 2023
fa8ffda
typo
oshai Jan 31, 2023
196850c
remove jcenter
oshai Jan 31, 2023
ef3f28d
fix windows test
oshai Jan 31, 2023
1c152ac
bump version to 4.0.0-beta-1
oshai Jan 31, 2023
4b0b69d
add github-release-4.x to github actions
oshai Jan 31, 2023
c3b63b7
bump version to 4.0.0-beta-2
oshai Jan 31, 2023
170a203
change artifact name to kotlin-logging-mew
oshai Jan 31, 2023
9c9c341
change package to io.github.oshai
oshai Feb 2, 2023
3628df4
change group (coordinate) to io.github.oshai
oshai Feb 2, 2023
dc11aa0
bump version to 4.0.0-beta-3
oshai Feb 2, 2023
16e19c8
change repo url
oshai Feb 2, 2023
dd82ddc
change repo url
oshai Feb 2, 2023
d1e6e0b
change pom name
oshai Feb 2, 2023
b9c30d7
bump version to 4.0.0-beta-4
oshai Feb 2, 2023
74c8a3e
bump version to 4.0.0-beta-5
oshai Feb 2, 2023
4428078
change maven url
oshai Feb 2, 2023
b22c55d
bump version to 4.0.0-beta-6
oshai Feb 2, 2023
0a406e5
trying a different repo url
oshai Feb 2, 2023
468cb83
bump version to 4.0.0-beta-7
oshai Feb 2, 2023
1a02634
add credentials
oshai Feb 2, 2023
3b22398
add credentials from env
oshai Feb 2, 2023
cb00099
change url according to https://central.sonatype.org/publish/publish-…
oshai Feb 2, 2023
9696c93
trying not to release
oshai Feb 2, 2023
10c26d1
trying not to release #2
oshai Feb 2, 2023
f2f9b9f
trying not to release #3
oshai Feb 2, 2023
b1c74f1
trying not to release #5
oshai Feb 2, 2023
176b8f3
trying not to release #6
oshai Feb 2, 2023
77c15fb
bump version to 4.0.0-beta-10
oshai Feb 2, 2023
ec68a37
Merge branch 'master' into 4.x-2
oshai Feb 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- github-release
- github-release-4.x

jobs:
release:
Expand All @@ -16,12 +17,12 @@ jobs:
with:
java-version: 11
- name: Publish
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -no-daemon --no-parallel --stacktrace -DSONATYPE_USERNAME=$SONATYPE_USERNAME -DSONATYPE_PASSWORD=$SONATYPE_PASSWORD -DGPG_PRIVATE_PASSWORD=$GPG_PRIVATE_PASSWORD -DGPG_PRIVATE_KEY=$GPG_PRIVATE_KEY
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -no-daemon --no-parallel --stacktrace -DSONATYPE_USERNAME_2=$SONATYPE_USERNAME_2 -DSONATYPE_PASSWORD_2=$SONATYPE_PASSWORD_2 -DGPG_PRIVATE_PASSWORD=$GPG_PRIVATE_PASSWORD -DGPG_PRIVATE_KEY=$GPG_PRIVATE_KEY
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME_2: ${{ secrets.SONATYPE_USERNAME_2 }}
SONATYPE_PASSWORD_2: ${{ secrets.SONATYPE_PASSWORD_2 }}
SONATYPE_REPOSITORY_ID: ${{ needs.create_staging_repository.outputs.repository_id }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PRIVATE_PASSWORD: ${{ secrets.GPG_PRIVATE_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD_2 }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME_2 }}
18 changes: 13 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@ plugins {

apply("versions.gradle.kts")

group = "io.github.microutils"
version = "3.0.6"
group = "io.github.oshai"
version = "4.0.0-beta-10"

repositories {
mavenCentral()
}

nexusPublishing {
repositories {
sonatype()
sonatype { //only for users registered in Sonatype after 24 Feb 2021
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(System.getenv("SONATYPE_USERNAME_2")) // defaults to project.properties["myNexusUsername"]
password.set(System.getenv("SONATYPE_PASSWORD_2")) // defaults to project.properties["myNexusPassword"]
}
}
}

Expand Down Expand Up @@ -82,7 +87,7 @@ kotlin {
}
val jvmMain by getting {
dependencies {
api("org.slf4j:slf4j-api:${extra["slf4j_version"]}")
compileOnly("org.slf4j:slf4j-api:${extra["slf4j_version"]}")
}
}
val jvmTest by getting {
Expand All @@ -94,6 +99,9 @@ kotlin {
implementation("org.apache.logging.log4j:log4j-api:${extra["log4j_version"]}")
implementation("org.apache.logging.log4j:log4j-core:${extra["log4j_version"]}")
implementation("org.apache.logging.log4j:log4j-slf4j2-impl:${extra["log4j_version"]}")
implementation("org.slf4j:slf4j-api:${extra["slf4j_version"]}")
// our jul test just forward the logs jul -> slf4j -> log4j
implementation("org.slf4j:jul-to-slf4j:${extra["slf4j_version"]}")
}
}
val jsMain by getting {}
Expand Down Expand Up @@ -218,6 +226,6 @@ detekt {

val jvmJar by tasks.getting(Jar::class) {
manifest {
attributes("Automatic-Module-Name" to "io.github.microutils.kotlinlogging")
attributes("Automatic-Module-Name" to "io.github.oshai.kotlinlogging")
}
}
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.mpp.stability.nowarn=true
kotlin.native.ignoreDisabledTargets=true
# workaround for https://github.com/gradle/gradle/issues/11412
Expand Down
1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pluginManagement {
repositories {
gradlePluginPortal()
jcenter()
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package mu
package io.github.oshai

public expect interface KLogger {

/**
* Return the name of this `Logger` instance.
* @return name of this logger instance
*/
public val name: String

/** Lazy add a log message if isTraceEnabled is true */
public fun trace(msg: () -> Any?)

Expand Down Expand Up @@ -33,34 +39,34 @@ public expect interface KLogger {
public fun error(t: Throwable?, msg: () -> Any?)

/** Lazy add a log message with a marker if isTraceEnabled is true */
public fun trace(marker: Marker?, msg: () -> Any?)
public fun trace(marker: io.github.oshai.Marker?, msg: () -> Any?)

/** Lazy add a log message with a marker if isDebugEnabled is true */
public fun debug(marker: Marker?, msg: () -> Any?)
public fun debug(marker: io.github.oshai.Marker?, msg: () -> Any?)

/** Lazy add a log message with a marker if isInfoEnabled is true */
public fun info(marker: Marker?, msg: () -> Any?)
public fun info(marker: io.github.oshai.Marker?, msg: () -> Any?)

/** Lazy add a log message with a marker if isWarnEnabled is true */
public fun warn(marker: Marker?, msg: () -> Any?)
public fun warn(marker: io.github.oshai.Marker?, msg: () -> Any?)

/** Lazy add a log message with a marker if isErrorEnabled is true */
public fun error(marker: Marker?, msg: () -> Any?)
public fun error(marker: io.github.oshai.Marker?, msg: () -> Any?)

/** Lazy add a log message with a marker and throwable payload if isTraceEnabled is true */
public fun trace(marker: Marker?, t: Throwable?, msg: () -> Any?)
public fun trace(marker: io.github.oshai.Marker?, t: Throwable?, msg: () -> Any?)

/** Lazy add a log message with a marker and throwable payload if isDebugEnabled is true */
public fun debug(marker: Marker?, t: Throwable?, msg: () -> Any?)
public fun debug(marker: io.github.oshai.Marker?, t: Throwable?, msg: () -> Any?)

/** Lazy add a log message with a marker and throwable payload if isInfoEnabled is true */
public fun info(marker: Marker?, t: Throwable?, msg: () -> Any?)
public fun info(marker: io.github.oshai.Marker?, t: Throwable?, msg: () -> Any?)

/** Lazy add a log message with a marker and throwable payload if isWarnEnabled is true */
public fun warn(marker: Marker?, t: Throwable?, msg: () -> Any?)
public fun warn(marker: io.github.oshai.Marker?, t: Throwable?, msg: () -> Any?)

/** Lazy add a log message with a marker and throwable payload if isErrorEnabled is true */
public fun error(marker: Marker?, t: Throwable?, msg: () -> Any?)
public fun error(marker: io.github.oshai.Marker?, t: Throwable?, msg: () -> Any?)

/** Add a log message with all the supplied parameters along with method name */
public fun entry(vararg argArray: Any?)
Expand Down
7 changes: 7 additions & 0 deletions src/commonMain/kotlin/io/github/oshai/KMarkerFactory.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.github.oshai

/** A platform independent factory to create markers. */
public object KMarkerFactory {

public fun getMarker(name: String): io.github.oshai.Marker = io.github.oshai.SimpleMarker(name)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mu
package io.github.oshai

public expect object KotlinLogging {
/**
Expand All @@ -7,7 +7,7 @@ public expect object KotlinLogging {
* val logger = KotlinLogging.logger {}
* ```
*/
public fun logger(func: () -> Unit): KLogger
public fun logger(func: () -> Unit): io.github.oshai.KLogger

public fun logger(name: String): KLogger
public fun logger(name: String): io.github.oshai.KLogger
}
39 changes: 39 additions & 0 deletions src/commonMain/kotlin/io/github/oshai/Level.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package io.github.oshai

public enum class Level(private val levelInt: Int, private val levelStr: String) {
TRACE(io.github.oshai.Levels.TRACE_INT, "TRACE"),
DEBUG(io.github.oshai.Levels.DEBUG_INT, "DEBUG"),
INFO(io.github.oshai.Levels.INFO_INT, "INFO"),
WARN(io.github.oshai.Levels.WARN_INT, "WARN"),
ERROR(io.github.oshai.Levels.ERROR_INT, "ERROR"),
;

public fun toInt(): Int {
return levelInt
}

/** Returns the string representation of this Level. */
override fun toString(): String {
return levelStr
}
}

public object Levels {

public const val TRACE_INT: Int = 0
public const val DEBUG_INT: Int = 10
public const val INFO_INT: Int = 20
public const val WARN_INT: Int = 30
public const val ERROR_INT: Int = 40

public fun intToLevel(levelInt: Int): io.github.oshai.Level {
return when (levelInt) {
io.github.oshai.Levels.TRACE_INT -> io.github.oshai.Level.TRACE
io.github.oshai.Levels.DEBUG_INT -> io.github.oshai.Level.DEBUG
io.github.oshai.Levels.INFO_INT -> io.github.oshai.Level.INFO
io.github.oshai.Levels.WARN_INT -> io.github.oshai.Level.WARN
io.github.oshai.Levels.ERROR_INT -> io.github.oshai.Level.ERROR
else -> throw IllegalArgumentException("Level integer [$levelInt] not recognized.")
}
}
}
11 changes: 11 additions & 0 deletions src/commonMain/kotlin/io/github/oshai/Marker.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.github.oshai

/** A platform independent marker to enrich log statements. */
public interface Marker {

public fun getName(): String
}

internal data class SimpleMarker(private val name: String) : io.github.oshai.Marker {
override fun getName(): String = this.name
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mu.internal
package io.github.oshai.internal

@Suppress("NOTHING_TO_INLINE")
internal inline fun (() -> Any?).toStringSafe(): String {
Expand Down
7 changes: 0 additions & 7 deletions src/commonMain/kotlin/mu/KMarkerFactory.kt

This file was deleted.

7 changes: 0 additions & 7 deletions src/commonMain/kotlin/mu/Marker.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package mu
package io.github.oshai

import kotlin.test.Test

class SimpleTest {
private val logger = KotlinLogging.logger {}
private val logger = io.github.oshai.KotlinLogging.logger {}

@Test
fun simpleTest() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mu.internal
package io.github.oshai.internal

import kotlin.test.Test
import kotlin.test.assertEquals
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package mu
package io.github.oshai

public actual val DefaultAppender: Appender = OSLogAppender()
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mu
package io.github.oshai

import kotlinx.cinterop.ptr
import platform.darwin.OS_LOG_DEFAULT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mu
package io.github.oshai

import kotlin.native.concurrent.AtomicReference
import platform.darwin.os_log_create
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mu
package io.github.oshai

public interface Appender {
public fun trace(message: Any?)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mu
package io.github.oshai

public object ConsoleOutputAppender : Appender {
public override fun trace(message: Any?): Unit = console.log(message)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
package mu
package io.github.oshai

import mu.internal.toStringSafe
import io.github.oshai.internal.toStringSafe

public object DefaultMessageFormatter : Formatter {
public override fun formatMessage(
level: KotlinLoggingLevel,
loggerName: String,
msg: () -> Any?
): String = "${level.name}: [$loggerName] ${msg.toStringSafe()}"
public override fun formatMessage(level: Level, loggerName: String, msg: () -> Any?): String =
"${level.name}: [$loggerName] ${msg.toStringSafe()}"

public override fun formatMessage(
level: KotlinLoggingLevel,
level: Level,
loggerName: String,
t: Throwable?,
msg: () -> Any?
): String = "${level.name}: [$loggerName] ${msg.toStringSafe()}${t.throwableToString()}"

public override fun formatMessage(
level: KotlinLoggingLevel,
level: Level,
loggerName: String,
marker: Marker?,
msg: () -> Any?
): String = "${level.name}: [$loggerName] ${marker?.getName()} ${msg.toStringSafe()}"

public override fun formatMessage(
level: KotlinLoggingLevel,
level: Level,
loggerName: String,
marker: Marker?,
t: Throwable?,
Expand Down
14 changes: 14 additions & 0 deletions src/jsMain/kotlin/io/github/oshai/Formatter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.github.oshai

public interface Formatter {
public fun formatMessage(level: Level, loggerName: String, msg: () -> Any?): Any?
public fun formatMessage(level: Level, loggerName: String, t: Throwable?, msg: () -> Any?): Any?
public fun formatMessage(level: Level, loggerName: String, marker: Marker?, msg: () -> Any?): Any?
public fun formatMessage(
level: Level,
loggerName: String,
marker: Marker?,
t: Throwable?,
msg: () -> Any?
): Any?
}
Loading