Skip to content

Optimize the KLoggerNameResolver for jvm #484

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

Closed
scrat98 opened this issue Mar 6, 2025 · 1 comment · Fixed by #485
Closed

Optimize the KLoggerNameResolver for jvm #484

scrat98 opened this issue Mar 6, 2025 · 1 comment · Fixed by #485

Comments

@scrat98
Copy link
Contributor

scrat98 commented Mar 6, 2025

Part 1 of #480

Optimize the KLoggerNameResolver for jvm, since we don't need to search indexOf multiple times.

scrat98 added a commit to scrat98/kotlin-logging that referenced this issue Mar 6, 2025
…don't need to search indexOf multiple times
@scrat98
Copy link
Contributor Author

scrat98 commented Mar 6, 2025

@oshai Also please note, that KLoggerNameResolver::name(func: () -> Unit) is never used in the tests. Therefore I'm not sure should we apply the same logic for name(forClass: Class<T>). To do the following:

  /** get class name for function by the package of the function */
  internal actual fun name(func: () -> Unit): String {
    return name(func::class)
  }

  /** get class name for java class (that usually represents kotlin class) */
  internal fun name(clazz: KClass<*>): String {
    return clazz.java.name.toCleanClassName()
  }

The problem with that tests rely on the old behavior (with enclosingClass reflection), for example:

      Arguments.of(
        "io.github.oshai.kotlinlogging.internal.BaseClass\$InnerClass\$Obj",
        BaseClass.InnerClass.Obj::class.java,
      )

scrat98 added a commit to scrat98/kotlin-logging that referenced this issue Apr 6, 2025
scrat98 added a commit to scrat98/kotlin-logging that referenced this issue Apr 6, 2025
scrat98 added a commit to scrat98/kotlin-logging that referenced this issue Apr 6, 2025
oshai pushed a commit that referenced this issue Apr 16, 2025
* Issue #484 - 

Optimize the KLoggerNameResolver for jvm, since we don't need to search indexOf multiple times
update KLoggerNameResolver tests for jvm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant