Giter VIP home page Giter VIP logo

canard's Introduction

Maven Central Kotlin Github Actions MIT License Slack channel

Canard - Kotlin Multiplatform Logging library

Canard is a lightweight Kotlin Multiplatform logging library with a simple API, working on:

  • JVM / Android
  • iOS, as well as all Kotlin/Native targets
  • JavaScript / WasmJS

Canard allows you to:

  • Easily set up logging in a Kotlin Multiplatform
  • Log what you need on different levels
  • Avoid worrying about platform-specific frontend implementations

Canard is a good choice because:

  • It integrates nicely with all Kotlin/Multiplatform targets
  • It has a straightforward design with a user-friendly and comprehensible API.

Installation

repositories {
    mavenCentral()
}

kotlin {
    sourceSets {
        commonMain {
            dependencies {
                implementation("org.kodein.log:canard:{version}")
            }
        }
    }
}

Example

// Simple example
val loggerFactory = LoggerFactory(defaultLogFrontend)
val logger = newLogger(loggerFactory)

logger.info { "Welcome to ..." }
logger.warning { "... the Canard documentation!" }

Read more

See Canard documentation.

canard's People

Contributors

koridze avatar prototik avatar romainbsl avatar salomonbrys 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

Watchers

 avatar  avatar  avatar

canard's Issues

Update Kotlin version: 1.9.20 -> 1.9.21

Dear Library Maintainer,

We have just released Kotlin 1.9.21 that fixes critical issue that, in some cases, resulted in the production of incorrect klib libraries. Details: https://youtrack.jetbrains.com/issue/KT-62515. We have detected that there are libraries built with 1.9.20 that were published to Maven Central. And these libraries are affected by the issue:

org.kodein.log:canard:1.1.0

We highly recommend you rebuilding these libraries with 1.9.21 and republishing them to minimize possible negative impact. Please take our apologies for this inconvenience. We will take the necessary measures to avoid similar issues in the future.

Kotlin Team.

@js-joda/core could not be found - jsMain logging in KMM project

I'm facing an issue when tried to do any logging in JS in a KMM project.
I'm using the latest 0.16 version of canard, see excerpt from the build.gradle.kts

val commonMain by getting {
            dependencies {
                ...
                implementation("org.kodein.log:canard:0.16.0")
                implementation("org.kodein.di:kodein-di:7.14.0")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.0")
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
                ...
            }
        }

See stack trace:

Unable to resolve module @js-joda/core from <project_src>/node_modules/<js_lib_folder_name>/Kotlin-DateTime-library-kotlinx-datetime-js-ir.js: @js-joda/core could not be found within the project or in these directories:
  ../node_modules
  1716 |   //endregion
  1717 |   return _;
> 1718 | }(module.exports, require('@js-joda/core'), require('./kotlin-kotlin-stdlib-js-ir.js'), require('./kotlinx-serialization-kotlinx-serialization-core-js-ir.js')));
       |                            ^
  1719 |
  1720 | //# sourceMappingURL=Kotlin-DateTime-library-kotlinx-datetime-js-ir.js.map
  1721 |

A possible workaround I found for the issue is to add the @js-joda/core as an npm dependency to the jsMain sourceSet definition.

val jsMain by getting {
            dependsOn(commonMain)
            dependencies {
                implementation(npm("@js-joda/core", "5.4.2"))
            }
        }

Having this in the sourceSet closure, I am able to use canard in JS and I can see the logs with the default LoggingFactory in the console.

Can't be used on Android < 26 (Java 7)

Similar to: Kotlin/kotlinx-datetime#97

java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/Instant;
        at kotlinx.datetime.Instant.<clinit>(Instant.kt:94)
        at kotlinx.datetime.Clock$System.now(Clock.kt:14)
        at org.kodein.log.InstantDateTimeKt.now(instantDateTime.kt:9)
        at org.kodein.log.Logger$Entry.<init>(Logger.kt:90)
        at org.kodein.log.Logger.createEntry(Logger.kt:94)

Crash in kotlinx-datetime

We are seeing a crash with this code flow:

Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault())

Steps to reproduce:

  • Set an iPhone to timezone: Kolkata, India (Settings > General >Date & Time)
  • Run code on iPhone device

In particular, the function toLocalDateTime is crashing:

Caused by: kotlin.RuntimeException: Unable to acquire the offset at instant 2021-04-06T18:14:34.809669017Z for zone Asia/Kolkata
at 0 PhoenixShared 0x0000000103a5982c kfun:kotlin.Throwable#(kotlin.String?){} + 96
at 1 PhoenixShared 0x0000000103a5198c kfun:kotlin.Exception#(kotlin.String?){} + 92
at 2 PhoenixShared 0x0000000103a51bfc kfun:kotlin.RuntimeException#(kotlin.String?){} + 92
at 3 PhoenixShared 0x0000000103c6ebcc kfun:kotlinx.datetime.TimeZone#offsetAtImpl(kotlinx.datetime.Instant){}kotlinx.datetime.ZoneOffset + 768
at 4 PhoenixShared 0x0000000103c70dd0 kfun:kotlinx.datetime#[email protected](kotlinx.datetime.Instant){}kotlinx.datetime.ZoneOffset + 188
at 5 PhoenixShared 0x0000000103c62aac kfun:kotlinx.datetime#[email protected](kotlinx.datetime.TimeZone){}kotlinx.datetime.ZoneOffset + 168
at 6 PhoenixShared 0x0000000103c71a3c kfun:kotlinx.datetime#[email protected](kotlinx.datetime.TimeZone){}kotlinx.datetime.ZonedDateTime + 268
at 7 PhoenixShared 0x0000000103c6e6fc kfun:kotlinx.datetime.TimeZone#[email protected](){}kotlinx.datetime.LocalDateTime + 272
at 8 PhoenixShared 0x0000000103c6ff9c kfun:kotlinx.datetime#[email protected](kotlinx.datetime.TimeZone){}kotlinx.datetime.LocalDateTime + 172
at 9 PhoenixShared 0x0000000103c7e620 kfun:org.kodein.log#[email protected](){}kotlin.String + 224
at 10 PhoenixShared 0x0000000103c7b3d0 kfun:org.kodein.log.frontend#printLogIn(org.kodein.log.Logger.Tag;org.kodein.log.Logger.Entry;kotlin.String?;kotlin.Function1<kotlin.String,kotlin.Unit>){} + 1052

Possible related issue

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.