Giter Site home page Giter Site logo

aakira / napier Goto Github PK

View Code? Open in Web Editor NEW
692.0 10.0 33.0 3.11 MB

Logging library for Kotlin Multiplatform

License: Apache License 2.0

Kotlin 70.71% Swift 22.87% Shell 0.25% Ruby 5.23% Makefile 0.13% HTML 0.81%
kotlin-multiplatform kotlin-library kotlin-native kotlin-js

napier's Introduction

logo

Napier is a logger library for Kotlin Multiplatform.
It supports Android, Darwin(iOS, macOS, watchOS, tvOS), JVM, JavaScript.
Logs written in common module are displayed on logger viewer of each platform.

Preview

Android

format: [Class name]$[Method name]: [Your log]

uses the android.util.Log(Logcat)

preview-android

Darwin(iOS, macOS, watchOS, tvOS)[Intel/Apple silicon]

format: [Date time][Symbol][Log level][Class name].[Method name] - [Your log]

Added [async] label at the end, if it is called from suspend functions.

uses the print

preview-ios

JavaScript

uses the console.log

preview-js

JVM

uses the java.util.logging.Logger

preview-jvm

  • common sample code
class Sample {

    fun hello(): String {
        Napier.v("Hello napier")
        Napier.d("optional tag", tag = "your tag")

        return "Hello Napier"
    }

    suspend fun suspendHello(): String {
        Napier.i("Hello")

        delay(3000L)

        Napier.w("Napier!")

        return "Suspend Hello Napier"
    }

    fun handleError() {
        try {
            throw Exception("throw error")
        } catch (e: Exception) {
            Napier.e("Napier Error", e)
        }
    }
}

Download

Repository

You can download this library from MavenCentral or jCenter repository.

  • Maven central

You can download this from 1.4.1.
Package name is io.github.aakira

repositories {
    mavenCentral()
}
  • jCenter

You can download this until 1.4.1.
Package name is com.github.aakira

repositories {
    jCenter()
}

Version

Set the version name in your build.gradle

Maven Central

def napierVersion = "[latest version]"

Common

Add the dependency to your commonMain dependencies

  • groovy
sourceSets {
    commonMain {
        dependencies {
            // ...
            implementation "io.github.aakira:napier:$napierVersion"
        }
    }
}
  • kts
sourceSets {
    val commonMain by getting {
        dependencies {
            implementation("io.github.aakira:napier:$napierVersion")
        }
    }
}

Usage

How to use

Common module

// verbose log
Napier.v("Hello napier")
Napier.v { "Hello napier" }

// you can set a tag for each log
Napier.d("optional tag", tag = "your tag")
Napier.d(tag = "your tag") { "optional tag" }

try {
    ...
} catch (e: Exception) {
    // you can set the throwable
    Napier.e("Napier Error", e)
    Napier.e(e) { "Napier Error" }
}

// you can also use top-level function
log { "top-level" }
log(tag = "your tag") { "top-level" }

Initialize

You must initialize the Napier in your module.

Android

Napier.base(DebugAntilog())

iOS

  • Write initialize code in your kotlin mpp project.
fun debugBuild() {
    Napier.base(DebugAntilog())
}

|argument|type|description| |-|-| |coroutinesSuffix|Boolean|Added [async] label at the end, if it is called from suspend functions|

  • Call initialize code from ios project.
NapierProxyKt.debugBuild()

Clear antilog

Napier.takeLogarithm()

Log level

Platform Sample
VERBOSE Napier.v()
DEBUG Napier.d()
INFO Napier.i()
WARNING Napier.w()
ERROR Napier.e()
ASSERT Napier.wtf()

Run background thread

You can use this library on the background thread on iOS using Kotlin.coroutines as native-mt.

  • Define scope
internal val mainScope = SharedScope(Dispatchers.Main)

internal val backgroundScope = SharedScope(Dispatchers.Default)

internal class SharedScope(private val context: CoroutineContext) : CoroutineScope {
    private val job = Job()
    private val exceptionHandler = CoroutineExceptionHandler { _, throwable ->
        println("[Coroutine Exception] $throwable")
    }

    override val coroutineContext: CoroutineContext
        get() = context + job + exceptionHandler
}
  • Usage
backgroundScope.launch {
    suspendFunction()
}

Advancement

You can inject custom Antilog.
So, you should change Antilogs in debug build or release build.

Crashlytics

Crashlytics AntiLog samples

Sample projects use the Firebase Crashlytics.
You must set authentication files to android/google-services.json and ios/Napier/GoogleService-Info.plist.

Check the firebase document. [Android, iOS]

Write this in your application class.

if (BuildConfig.DEBUG) {
    // Debug build

    // disable firebase crashlytics
    FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(false)
    // init napier
    Napier.base(DebugAntilog())
} else {
    // Others(Release build)

    // enable firebase crashlytics
    FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true)
    // init napier
    Napier.base(CrashlyticsAntilog(this))
}

Write this in your AppDelegate.

#if DEBUG
// Debug build

// init napier
NapierProxyKt.debugBuild()

#else
// Others(Release build)

// init firebase crashlytics
FirebaseApp.configure()

// init napier
NapierProxyKt.releaseBuild(antilog: CrashlyticsAntilog(
    crashlyticsAddLog: { priority, tag, message in
        Crashlytics.crashlytics().log("\(String(describing: tag)): \(String(describing: message))")
},
    crashlyticsSendLog: { throwable in
        Crashlytics.crashlytics().record(error: throwable)
}))
#endif

License

Copyright (C) 2019 A.Akira

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Credit

This library is inspired by Timber.
I recommend using it if it supports kotlin multiplatform project.๐Ÿ˜œ

Thanks for advice.
@horita-yuya, @terachanple

napier's People

Contributors

aakira avatar chatton-trimble avatar colagom avatar dependabot[bot] avatar ghasemdev avatar horita-yuya avatar keeeeen avatar philipdukhov avatar terachanple avatar terrakok avatar yshrsmz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

napier's Issues

Could not resolve com.github.aakira:napier-android:1.4.1

Hi!
Updated to version 1.4.1 from 1.3.9, tried to run a :commonCode:build task and got this

`> Could not resolve all artifacts for configuration ':commonCode:debugCompileClasspath'.

Could not resolve com.github.aakira:napier-android:1.4.1.
Required by:
project :commonCode
> No matching variant of com.github.aakira:napier-android:1.4.1 was found. The consumer was configured to find an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
- Variant 'android-releaseApiElements' capability com.github.aakira:napier-android:1.4.1 declares an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug'
- Variant 'android-releaseRuntimeElements' capability com.github.aakira:napier-android:1.4.1 declares a runtime of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug'
- Variant 'metadata-api' capability com.github.aakira:napier-android:1.4.1:
- Incompatible because this component declares a usage of 'kotlin-metadata' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'
- Other compatible attribute:
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
- Variant 'metadata-commonMainMetadataElements' capability com.github.aakira:napier-android:1.4.1:
- Incompatible because this component declares a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'
- Other compatible attribute:
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
`

Failed to build with real iOS device

I got following error while building iOS app for real device.

w: skipping /Users/user/.gradle/caches/modules-2/files-2.1/com.github.aakira/napier-ios/0.0.4/aa6805b163ff862b63e862f4e63fa7852ca4d751/napier-ios-0.0.4.klib. The target doesn't match. Expected 'ios_arm64', found [ios_x64]

It looks like napier-ios artifact is for iOS simulator.

Please consider either of these;

  • mention other iOS artifacts(napier-iosArm34 and napier-iosArm64) in README and add how we should use these three
  • make napier-ios ios common module, and let Gradle choose appropriate module depending on target iOS cpu architecture.

https://repo.maven.apache.org/maven2/com/squareup/sqldelight/ios-driver/1.1.3/
this link is the example of iOS common artifact.
As you can see, common module should include *.module file to choose appropriate artifact for different variants.

Kotlin 1.3.60 support

Kotlin/Native require same version of compilator for used libraries. To continue usage of Napier in my projects library should be updated to 1.3.60. Have you plans for it?

Napier.base documentation

It is not clear from documentation if Napier.base should be called only in debug builds like

if (BuildConfig.DEBUG) {
        Napier.base(DebugAntilog())
}

or does the call do it internally?

Could not resolve com.github.aakira:napier-android:1.4.1

Was wrong closing a previous issue, sorry

Updated to version 1.4.1 from 1.3.9, tried to run a :commonCode:build task and got this

`
Could not determine the dependencies of task ':commonCode:lint'.
Could not resolve all artifacts for configuration ':commonCode:debugCompileClasspath'.

Could not resolve com.github.aakira:napier-android:1.4.1.
Required by:
project :commonCode
> No matching variant of com.github.aakira:napier-android:1.4.1 was found. The consumer was configured to find an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
- Variant 'android-releaseApiElements' capability com.github.aakira:napier-android:1.4.1 declares an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug'
- Variant 'android-releaseRuntimeElements' capability com.github.aakira:napier-android:1.4.1 declares a runtime of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug'
- Variant 'metadata-api' capability com.github.aakira:napier-android:1.4.1:
- Incompatible because this component declares a usage of 'kotlin-metadata' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'
- Other compatible attribute:
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
- Variant 'metadata-commonMainMetadataElements' capability com.github.aakira:napier-android:1.4.1:
- Incompatible because this component declares a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'
- Other compatible attribute:
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
`

Wrong stack trace index after using Swift wrapper

I would like to use Napier in iOS part as well. This is not very convenient because Kotlin Native has some limitations:

  1. The converted code cannot have default parameters, so I had to specify throwable and tag in every call.
  2. The converted code cannot be used as a static function, and shared/Companion() must be specified manually.
  3. Because of the () -> String methods, the argument name tag cannot be used in both cases, and the String variant has the name tag_.

So my log code can look like this:

Napier.shared.d(message: "", throwable: nil, tag_: nil)

As far as I know, you can't do anything about these problems in kotlin part. That's why I wrote such a wrapper in Swift:

extension Napier {
    static func d(tag: String? = nil, _ items: Any..., separator: String = " ") {
        shared.d(message: items.joined(separator: separator), throwable: nil, tag_: tag)
    }
}

Everything works as expected, with one exception: because you use a constant stack trace index, the function name calculation is no longer correct.

I thought about adding another optional parameter to all calls that would indicate the shift in wrappers like mine, something like this:

fun d(message: String, throwable: Throwable? = null, tag: String? = null, stackTraceIndexShift: Int = 0) {
    // ...
}
extension Napier {
    static func d(tag: String? = nil, _ items: Any..., separator: String = " ") {
        shared.d(message: items.joined(separator: separator), throwable: nil, tag_: tag, stackTraceIndexShift: 1)
    }
}

But maybe you can come up with a more elegant solution

ArrayIndexOutOfBoundsException in performTag method for Android

I am experiencing a recurring crash in my application, which seems to be related to an ArrayIndexOutOfBoundsException. The stack trace is as follows:

Exception java.lang.ArrayIndexOutOfBoundsException: length=9; index=9
    at io.github.aakira.napier.DebugAntilog.performTag (DebugAntilog.java:78)
    at io.github.aakira.napier.DebugAntilog.performLog (DebugAntilog.java:78)
    at io.github.aakira.napier.Antilog.rawLog$napier_release (Antilog.java:78)
    at io.github.aakira.napier.Napier.rawLog (Napier.kt:78)
    at io.github.aakira.napier.Napier.log (Napier.kt:78)
    at io.github.aakira.napier.Napier.e (Napier.kt:136)
    at io.github.aakira.napier.Napier.e$default (Napier.java:136)

Code Inspection:
Upon reviewing the related code, I noticed the potential cause in the performTag function:

private fun performTag(tag: String): String {
    val thread = Thread.currentThread().stackTrace

    return if (thread.size >= CALL_STACK_INDEX) {
        thread[CALL_STACK_INDEX].run {
            "${createStackElementTag(className)}\$$methodName"
        }
    } else {
        tag
    }
}

Possible Solution:
It appears that replacing thread.size >= CALL_STACK_INDEX with thread.size > CALL_STACK_INDEX could resolve the issue.

Question:
Is this indeed a bug, or am I missing some other aspect of the implementation that could be causing this error?

Unresolved reference: Napier

hi, i'm getting Unresolved reference: Napier when trying to run this library. This is my gradle setup:

  sourceSets["commonMain"].dependencies {

        // Logging
        implementation("com.github.aakira:napier:${ extra.get("napierVersion") }")
    }
 sourceSets["androidMain"].dependencies {
       
        // Logging
        implementation("com.github.aakira:napier-android:${ extra.get("napierVersion") }")
    }
sourceSets["iosMain"].dependencies 

        // Logging
        implementation("com.github.aakira:napier-ios:${ extra.get("napierVersion") }")
    }

i can import and use this library with no error in IDE, but when trying to compile i get the error.

please help.

Unresolved reference: Napier

I've got an issue when trying to use the Napier logging library in the kotlin mpp project. The symptoms are exactly the same as described in the Issue 26 which has been closed.

To test the issue out of my project I have downloaded the official Kotlin mpp example and just upgraded the versions of gradle and kotlin and added the Napier library. You can find the project here:
mpp-example.zip

I'm getting the error e: ...\mpp-example\greeting\src\commonMain\kotlin\common.kt: (3, 33): Unresolved reference: Napier

Handling Swift exceptions

Hello @AAkira

I develop KMM app and want to use Napier both for Android and iOS.

According to Napier README.md we can handle errors in Kotlin code like that

fun handleError() {
    try {
            throw Exception("throw error")
        } catch (e: Exception) {
            Napier.e("Napier Error", e)
    }
}

Is is possible to handle Error / NSError in a similar way in Swift code? May be another way to handle exceptions in iOS app?

Macos target

Hello! Have you any plans about native (macosX64 and others) target support?

Could not resolve all files for configuration ':project-name:iosArm64CompilationDependenciesMetadata' in 2.7.0

After updating from 2.6.1 to 2.7.0, we get the following error during during build:

> Could not resolve all files for configuration ':project-name:iosArm64CompilationDependenciesMetadata'.
   > Could not resolve io.github.aakira:napier:2.7.0.
     Required by:
         project :project-name
      > No matching variant of io.github.aakira:napier:2.7.0 was found. The consumer was configured to find a library for use during 'kotlin-metadata', preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native', attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64' but:
          - Variant 'debugApiElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during compile-time:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'debugRuntimeElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during runtime:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'debugSourcesElements-published' capability io.github.aakira:napier:2.7.0 declares a component for use during runtime:
              - Incompatible because this component declares documentation, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'iosSimulatorArm64ApiElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_simulator_arm64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'iosSimulatorArm64MetadataElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_simulator_arm64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'iosSimulatorArm64SourcesElements-published' capability io.github.aakira:napier:2.7.0 declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares documentation for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_simulator_arm64' and the consumer needed a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'iosX64ApiElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_x64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'iosX64MetadataElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_x64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'iosX64SourcesElements-published' capability io.github.aakira:napier:2.7.0 declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares documentation for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_x64' and the consumer needed a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'jsApiElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-api':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'jsRuntimeElements-published' capability io.github.aakira:napier:2.7.0 declares a library:
              - Incompatible because this component declares a component for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js' and the consumer needed a component for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'jsSourcesElements-published' capability io.github.aakira:napier:2.7.0:
              - Incompatible because this component declares documentation for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js' and the consumer needed a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'jvmApiElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during compile-time:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'jvmRuntimeElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during runtime:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'jvmSourcesElements-published' capability io.github.aakira:napier:2.7.0 declares a component for use during runtime:
              - Incompatible because this component declares documentation, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'macosArm64ApiElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'macos_arm64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'macosArm64MetadataElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'macos_arm64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'macosArm64SourcesElements-published' capability io.github.aakira:napier:2.7.0 declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares documentation for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.native.target' with value 'macos_arm64' and the consumer needed a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'macosX64ApiElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'macos_x64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'macosX64MetadataElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'macos_x64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'macosX64SourcesElements-published' capability io.github.aakira:napier:2.7.0 declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares documentation for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.native.target' with value 'macos_x64' and the consumer needed a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'metadataApiElements' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-metadata':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'metadataSourcesElements' capability io.github.aakira:napier:2.7.0:
              - Incompatible because this component declares documentation for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'releaseApiElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during compile-time:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'releaseRuntimeElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during runtime:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'releaseSourcesElements-published' capability io.github.aakira:napier:2.7.0 declares a component for use during runtime:
              - Incompatible because this component declares documentation, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'tvosSimulatorArm64ApiElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'tvos_simulator_arm64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'tvosSimulatorArm64MetadataElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'tvos_simulator_arm64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'tvosSimulatorArm64SourcesElements-published' capability io.github.aakira:napier:2.7.0 declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares documentation for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.native.target' with value 'tvos_simulator_arm64' and the consumer needed a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'tvosX64ApiElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'tvos_x64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'tvosX64MetadataElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'tvos_x64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'tvosX64SourcesElements-published' capability io.github.aakira:napier:2.7.0 declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares documentation for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.native.target' with value 'tvos_x64' and the consumer needed a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'wasmJsApiElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-api':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'wasmJsRuntimeElements-published' capability io.github.aakira:napier:2.7.0 declares a library:
              - Incompatible because this component declares a component for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' and the consumer needed a component for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'wasmJsSourcesElements-published' capability io.github.aakira:napier:2.7.0:
              - Incompatible because this component declares documentation for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' and the consumer needed a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'ios_arm64')
          - Variant 'watchosSimulatorArm64ApiElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'watchos_simulator_arm64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'watchosSimulatorArm64MetadataElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'watchos_simulator_arm64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'watchosSimulatorArm64SourcesElements-published' capability io.github.aakira:napier:2.7.0 declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares documentation for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.native.target' with value 'watchos_simulator_arm64' and the consumer needed a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'watchosX64ApiElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'watchos_x64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'watchosX64MetadataElements-published' capability io.github.aakira:napier:2.7.0 declares a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'watchos_x64' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
          - Variant 'watchosX64SourcesElements-published' capability io.github.aakira:napier:2.7.0 declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native':
              - Incompatible because this component declares documentation for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.native.target' with value 'watchos_x64' and the consumer needed a library for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.native.target' with value 'ios_arm64'
              - Other compatible attribute:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)

It's Hard to use with cocospoad

Please make a common module for iOS, for me I config the gradle like this:

val iosMain by creating {
            dependsOn(commonMain)
            dependencies {
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serializationVersion")
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutineVersion")
                implementation("io.ktor:ktor-client-ios:$ktorVersion")
                implementation("io.ktor:ktor-client-core-native:$ktorVersion")
            }
        }
        val iosTest by creating {
            dependsOn(commonTest)
        }

        iosArm32().compilations["test"].defaultSourceSet {
            dependsOn(iosTest)
        }
        iosArm32().compilations["main"].defaultSourceSet {
            dependsOn(iosMain)
            dependencies {
                implementation("com.github.aakira:napier-iosArm32:$napierVersion")
            }
        }
        iosArm64().compilations["test"].defaultSourceSet {
            dependsOn(iosTest)
        }
        iosArm64().compilations["main"].defaultSourceSet {
            dependsOn(iosMain)
            dependencies {
                implementation("com.github.aakira:napier-iosArm64:$napierVersion")
            }
        }
        iosX64().compilations["test"].defaultSourceSet {
            dependsOn(iosTest)
        }
        iosX64().compilations["main"].defaultSourceSet {
            dependsOn(iosMain)
            dependencies {
                implementation("com.github.aakira:napier-ios:$napierVersion")
            }
        }

And it could not be resolve in iosProject:
image

warning

Screenshot 2021-05-26 at 4 24 33 PM

i am getting a warning to remove jcenter() in am developing app in kotlin kmm but i remove jcenter() the libary doesnot work.

> Could not find io.github.aakira:napier:napier V 2.6.1

       val commonMain by getting {
            dependencies {
                implementation("com.github.aakira:napier:2.6.1")
            }
        }
Could not resolve all dependencies for configuration ':shared:iosSimulatorArm64CompileKlibraries'.
> Could not find io.github.aakira:napier:napier.
  Searched in the following locations:
    - https://dl.google.com/dl/android/maven2/io/github/aakira/napier/napier/napier-napier.pom
    - https://repo.maven.apache.org/maven2/io/github/aakira/napier/napier/napier-napier.pom
  Required by:
      project :shared

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

Any ideas?

Logging from another thread on iOS

Hi.
I've tried to call Napier.v on iOS inside of withContext(Dispatchers.Default) i.e. from a non-main thread and didn't get anything logged.
I see you use ThreadLocal annotation for Napier. And it seems on iOS I need to initialize Napier separately for Dispatchers.Default thread. Probably it worth adding support for logging from a non-main thread by default as now it looks like a bug.

In this example, I see only the first message logged on iOS. But the both messages are logged on Android. If I add Napier initialization inside of Dispatchers.Default, the both messages will be logged on iOS too:

suspend fun loadDefinition(word: String): OwlBotWord {
        Napier.v("Loading definition for: $word", tag = TAG)

        val res: HttpResponse = httpClient.get("${baseUrl}api/v4/dictionary/${word}")
        return withContext(Dispatchers.Default) {
            // If I initialize Napper here the second message will be logged
            val response = res.readBytes().decodeToString()
            if (res.status == HttpStatusCode.OK) {
                Napier.v("Loded definition for: $word", tag = TAG)
            } else {
                Napier.e("Status: ${res.status} response: $response", tag = TAG)
            }
            Json {
                ignoreUnknownKeys = true
            }.decodeFromString(response)
        }
    }

For now I've ended up with calling this on iOS in a setup function:

    private val defaultScope = CoroutineScope(Dispatchers.Default + SupervisorJob())

    actual fun setupDebug() {
        Napier.base(DebugAntilog())

        defaultScope.launch {
            Napier.base(DebugAntilog())
        }
    }

It isn't work

Hi. I am trying to use the library, but I faced with an issue. Log wasn't shown in console. It is reproduce on 2 systems, iOS and Android.

Does not work within async

I am trying to log with Napier from within an async block.

fun testLog() = coroutineScope {
    someList.map { element ->
        async {
            Napier.d( "Processing $element")
            someSuspendFunc(element)
            Napier.d("Done processing $element")
        }
    }.awaitAll()
}

Running the code in iOS gives the following error:

kotlin.native.IncorrectDereferenceException: Trying to access top level value not marked as @ThreadLocal or @SharedImmutable from non-main thread

Any solution for this?

ArtifactNotFoundException: Could not find napier-1.5.0-samplessources.jar (io.github.aakira:napier:1.5.0)

Hi, I am getting this error when I'm trying to import Napier from mavenCentral().

Failed building KotlinMPPGradleModel

org.gradle.internal.resolve.ArtifactNotFoundException: Could not find napier-1.5.0-samplessources.jar (io.github.aakira:napier:1.5.0).
Searched in the following locations:
    https://repo.maven.apache.org/maven2/io/github/aakira/napier/1.5.0/napier-1.5.0-samplessources.jar
	at org.gradle.internal.resolve.result.DefaultBuildableArtifactResolveResult.notFound(DefaultBuildableArtifactResolveResult.java:28)

I'm using

Android Studio Arctic Fox | 2020.3.1 Canary 15
Build #AI-203.7717.56.2031.7321754, built on April 29, 2021
macOS 11.2.3
Gradle 6.7.1

This is part of build.gradle.kts in the root project.

buildscript {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()

        // sqldelight
        maven { url = uri("https://www.jetbrains.com/intellij-repository/releases") }
        maven { url = uri("https://jetbrains.bintray.com/intellij-third-party-dependencies") }
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()

        // sqldelight
        maven { url = uri("https://www.jetbrains.com/intellij-repository/releases") }
        maven { url = uri("https://jetbrains.bintray.com/intellij-third-party-dependencies") }
    }
}

Some help would be very appreciated.

Add a way to remove Antilog

Like Timber's Timber#uprootAll(), it would be great if we have an option to remove already-added Antilogs.

In my case, if I try to use Napier in a Test and the test class has more than one test cases, Napier.base() is called multiple times, so same Antilog is added multiple times. Thus the same log is printed numerous times.

class LogTest {

  @BeforeTest
  fun setup() {
    // this is called once per a test case, so same Antilog is added multiple times.
	Napier.base(DebugAntilog())
  }

  @AfterTest
  fun tearDown() {
    // Napier.clearAntilog() // we need this!
  }

  @Test
  fun test1() {
    Napier.d("test1")
    // stdout:
    // test1
  }

  @Test
  fun test2() {
    Napier.d("test2")
    // stdout:
    // test2
    // test2
  }
}

2.6.0 does not have android-related artifacts

error log

* What went wrong:
Execution failed for task ':data:local:compileDebugKotlinAndroid'.
> Error while evaluating property 'filteredArgumentsMap' of task ':data:local:compileDebugKotlinAndroid'
   > Could not resolve all files for configuration ':data:local:debugCompileClasspath'.
      > Could not find io.github.aakira:napier-android-debug:2.6.0.
        Required by:
            project :data:local > io.github.aakira:napier:2.6.0

https://search.maven.org/artifact/io.github.aakira/napier-android
https://search.maven.org/artifact/io.github.aakira/napier-android-debug

Failed to resolve dependencies

I am working on sample mpp project and trying to use Napier as a logger. But when I am adding ios specific deps it is saying that

Could not determine the dependencies of task ':shared:linkReleaseFrameworkIos'.
> Could not resolve all task dependencies for configuration ':shared:iosCompileKlibraries'.
   > Could not resolve com.github.aakira:napier-iosArm32:1.2.0.
     Required by:
         project :shared
      > Unable to find a matching variant of com.github.aakira:napier-iosArm32:1.2.0:
          - Variant 'iosArm32-api' capability com.github.aakira:napier-iosArm32:1.2.0:
              - Incompatible attribute:
                  - Required org.jetbrains.kotlin.native.target 'ios_x64' and found incompatible value 'ios_arm32'.
              - Other attributes:
                  - Found org.gradle.status 'release' but wasn't required.
                  - Required org.gradle.usage 'kotlin-api' and found compatible value 'kotlin-api'.
                  - Required org.jetbrains.kotlin.platform.type 'native' and found compatible value 'native'.
          - Variant 'metadata-api' capability com.github.aakira:napier-iosArm32:1.2.0:
              - Incompatible attribute:
                  - Required org.jetbrains.kotlin.platform.type 'native' and found incompatible value 'common'.
              - Other attributes:
                  - Found org.gradle.status 'release' but wasn't required.
                  - Required org.gradle.usage 'kotlin-api' and found compatible value 'kotlin-api'.
                  - Required org.jetbrains.kotlin.native.target 'ios_x64' but no value provided.
   > Could not resolve com.github.aakira:napier-iosArm64:1.2.0.
     Required by:
         project :shared
      > Unable to find a matching variant of com.github.aakira:napier-iosArm64:1.2.0:
          - Variant 'iosArm64-api' capability com.github.aakira:napier-iosArm64:1.2.0:
              - Incompatible attribute:
                  - Required org.jetbrains.kotlin.native.target 'ios_x64' and found incompatible value 'ios_arm64'.
              - Other attributes:
                  - Found org.gradle.status 'release' but wasn't required.
                  - Required org.gradle.usage 'kotlin-api' and found compatible value 'kotlin-api'.
                  - Required org.jetbrains.kotlin.platform.type 'native' and found compatible value 'native'.
          - Variant 'metadata-api' capability com.github.aakira:napier-iosArm64:1.2.0:
              - Incompatible attribute:
                  - Required org.jetbrains.kotlin.platform.type 'native' and found incompatible value 'common'.
              - Other attributes:
                  - Found org.gradle.status 'release' but wasn't required.
                  - Required org.gradle.usage 'kotlin-api' and found compatible value 'kotlin-api'.
                  - Required org.jetbrains.kotlin.native.target 'ios_x64' but no value provided.

Could you please take a look?
https://github.com/BulatMukhutdinov/KittyGram/blob/master/shared/build.gradle.kts#L98

Imported declaration 'SharedNapierNapierLevel' could not be mapped to 'NapierNapier.Level'

I'm using Napier for Android/iOS multiplatform project. I'm getting such warning on __attribute__((swift_name("NapierNapier.Level"))) line.
Also when I tried to pass NapierNapier.Level as a parameter of crashlyticsAddLog lambda, kotlin didn't generated an initializer in obj-c code at all. I've tried some simple enums in my shared code, and those are available in my iOS code, so It's strange that enum from Napier is not.
Perfectly I'd like to use the enum, but at least I don't want that warning in Xcode, when I pass Int.

Double logging on Android LogCat makes Napier unusable

For some reason, every Napier log in Androids LogCat is duplicated with these tags:

W/System.err <message>
I/DebugAntilog <message>

The double logging makes log output unreadable to the point I no longer want to use Napier.
Are others experiencing this issue; and is there an easy resolution?

I/DebugAntilog is expected; I can't see why W/System.err is being logged:
This is for all log levels, not just warnings or errors.

iOS logging is working as expected.

Add an option to use compact tag format to DebugAntilog

Method name etc in the tag can be verbose in some cases.

For example, error messages in the projects I'm working on are more or less unique. And there's no need for the detailed tags.

It takes more time and cognitive efforts to read log lines with long tags. And in this case it doesn't seem to provide enough value to justify it.

An option to use short tags seems like a reasonable addition. Class name as a tag would make logs look like default Android logs. Which is what lots of developers are used to.
And those who prefer long tags would still be able to use them.

Of course, there is an option to implement custom Antilog in a project. But it seems to be an extra effort multiplied by a number of platforms multiplied by a number of devs who prefer short tags :)

Another option with writing short tags for each Napier call manually would also be not the most pleasant thing.

What do you think?

Android minSdk version

Hi,

This library is exactly what we were looking for for our Kotlin Multiplatform project. One small issue: why is the minSdk set to 21? I tried checking at the source and changing it to 18 (in dependencies.gradle) and it still compiled. It would be great if minSdk can be lowered so it can be readily used in Android apps that support lower versions. The Android support library default is Android 4 (Sdk 14). Can the minSdk be lowered to 14?

Thanks!

-Mike

Napier 0.0.5 is now compiled with 1.3.40, thus cannot be used with 1.3.31

Got following error while building iOS app.

: skipping /Users/vagrant/.gradle/caches/modules-2/files-2.1/com.github.aakira/napier-ios/0.0.5/a09fe8774ff1c9cc6c793a1414a756d25ab65299/napier-ios-0.0.5.klib. The abi versions don't match. Expected '[8]', found '9'

w: The compiler versions don't match either. Expected '[1.2.1]', found '1.3-release-10826'

https://bintray.com/aakira/maven/napier/0.0.5

As you can see version publication date of 0.0.5 is Jun 26, which is strange.

It looks like 0.0.5 was re-compiled with 1.3.40 and re-uploaded while releasing 0.0.6.
Could you re-upload 0.0.5 compiled with Kotlin 1.3.31?

Strange JS target logic

Why for JS DebugAntilog implementation Verbose priority is muted?

override fun isEnable(priority: Napier.Level, tag: String?) =
    priority != Napier.Level.VERBOSE

Library is not resolved with Kotlin Multiplatform 1.6.10

build.gradle.kts:

plugins {
    id("org.jetbrains.kotlin.multiplatform") version "1.6.10" // Change version here
}

repositories {
    mavenCentral()
}

kotlin {
    targets {
        jvm()
    }

    sourceSets {
        commonMain {
            dependencies {
                implementation("io.github.aakira:napier:2.2.0")
            }
        }
    }
}

Run gradle assemble and see:

Execution failed for task ':compileKotlinMetadata'.
> Error while evaluating property 'filteredArgumentsMap' of task ':compileKotlinMetadata'
   > Could not resolve all files for configuration ':metadataCompileClasspath'.
      > Could not resolve io.github.aakira:napier:2.2.0.
        Required by:
            project :
         > The consumer was configured to find a usage of 'kotlin-api' of a library, preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common'. However we cannot choose between the following variants of io.github.aakira:napier:2.2.0:
             - commonMainMetadataElements
             - debugApiElements-published
             - debugRuntimeElements-published
             - iosArm64ApiElements-published
             - iosSimulatorArm64ApiElements-published
             - iosX64ApiElements-published
             - jsIrApiElements-published
             - jsLegacyApiElements-published
             - jvmApiElements-published
             - jvmRuntimeElements-published
             - macosArm64ApiElements-published
             - macosX64ApiElements-published
             - releaseApiElements-published
             - releaseRuntimeElements-published
             - tvosArm64ApiElements-published
             - tvosSimulatorArm64ApiElements-published
             - tvosX64ApiElements-published
             - watchosArm32ApiElements-published
             - watchosArm64ApiElements-published
             - watchosSimulatorArm64ApiElements-published
             - watchosX64ApiElements-published
           All of them match the consumer attributes:
             - Variant 'commonMainMetadataElements' capability io.github.aakira:napier:2.2.0 declares a usage of 'kotlin-api' of a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common':
                 - Unmatched attributes:
                     - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                     - Provides release status but the consumer didn't ask for it
             - โ€ฆ

Version 1.6.0 gives no such error.

So far, I had this problem with Napier only. So, I'm reporting it here.

Refresh CrashlyticsAntilog with new FirebaseCrashlytics methods

See https://firebase.google.com/docs/crashlytics/customize-crash-reports?platform=android

Example :
Crashlytics.getInstance().core.logException(it)
become
FirebaseCrashlytics.getInstance().recordException(it)

Proposal :

class CrashlyticsAntilog(private val context: Context) : Antilog() {

    override fun performLog(priority: Napier.Level, tag: String?, throwable: Throwable?, message: String?) {
        // send only error log
        if (priority < Napier.Level.ERROR) return
        FirebaseCrashlytics.getInstance().log("$tag : $message")

        throwable?.let {
            when {
                // e.g. http exception, add a customized your exception message
                // it is KtorException -> {
                //      FirebaseCrashlytics.getInstance().log(priority.ordinal, "HTTP Exception", it.response?.errorBody.toString())
                // }
            }
            FirebaseCrashlytics.getInstance().recordException(it)
        }
    }
}

Cannot access Antilog from swift.

Usecase: We want to create subclass of the Antilog abstract class in swift.

The warning is the following:

Imported declaration 'CommonNapierNapierLevel' could not be mapped to 'NapierNapier.Level'
5:28
__attribute__((swift_name("NapierNapier.Level")))

Because of it we cannot use anything which relates to the Napier.Level enum from swift code, therefore the Antilog superclass is empty.

As a workaround we created a similar class like the CrashlyticsAntilog in the example but would be better a bit if the library would not produce a warning.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.