Kommons Debug — Logo

Kommons Download from Maven Central Download from GitHub Packages Build Status Repository Size Repository Size

About

Kommons is a Kotlin Multiplatform Library to support print debugging.

Installation / Setup

Kommons Debug is hosted on GitHub with releases provided on Maven Central.

  • Gradle implementation("com.bkahlert.kommons:kommons-debug:0.1.0")

  • Maven

    <dependency>
        <groupId>com.bkahlert.kommons</groupId>
        <artifactId>kommons-debug</artifactId>
        <version>0.1.0</version>
    </dependency>

Features

Any?.render()

Renders any object depending on whether its toString() is overridden:

  • if there is a custom toString() it is simply used
  • if there is no custom toString() it is serialized in the form <TYPE>(key0=value0, key1=value=1, ..., keyN=valueN)

Examples

"string".render()               // string

class Foo(val bar: Any = "baz")
foo().render()                  // Foo(bar="baz")
foo(foo()).render()             // Foo(bar=Foo(bar="baz"))

Any.properties

Contains a map of the object’s properties with each entry representing the name and value of a property.

Examples

"string".properties               // { length: 6 }

class Foo(val bar: Any = "baz")
foo().properties                  // { bar: "baz" }
foo(foo()).properties             // { bar: { bar: "baz" } }

CharSequence.quoted

Contains this string wrapped in double quotes and backslashes, line feeds, carriage returns, tabs and double quotes escaped.

Examples

"string".quoted               // "string"
"""{ bar: "baz" }""".quoted   // "{ bar: \"baz\" }"

ToDo

  • detect circular dependencies (render(), properties)
  • Any?.trace
  • Any.typeString
  • Release How-To

Contributing

Want to contribute? Awesome! The most basic way to show your support is to star the project, or to raise issues. You can also support this project by making a Paypal donation to ensure this journey continues indefinitely!

Thanks again for your support, it is much appreciated! ?

License

MIT. See LICENSE for more details.

GitHub

View Github