{"id":13537061,"url":"https://github.com/Foso/Cabret-Log","last_synced_at":"2025-04-02T03:31:34.717Z","repository":{"id":50003105,"uuid":"321168163","full_name":"Foso/Cabret-Log","owner":"Foso","description":":pencil2: Method call logging for Kotlin Multiplatform","archived":true,"fork":false,"pushed_at":"2022-10-17T22:37:57.000Z","size":24397,"stargazers_count":195,"open_issues_count":4,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-03T02:32:16.132Z","etag":null,"topics":["debuglog","kotlin-compiler-plugin","kotlin-ios","kotlin-js","kotlin-multiplatform","kotlin-native"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Foso.png","metadata":{"files":{"readme":"Readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-13T21:55:56.000Z","updated_at":"2024-10-02T19:56:11.000Z","dependencies_parsed_at":"2023-01-20T02:56:43.136Z","dependency_job_id":null,"html_url":"https://github.com/Foso/Cabret-Log","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foso%2FCabret-Log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foso%2FCabret-Log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foso%2FCabret-Log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foso%2FCabret-Log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Foso","download_url":"https://codeload.github.com/Foso/Cabret-Log/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246751262,"owners_count":20827860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debuglog","kotlin-compiler-plugin","kotlin-ios","kotlin-js","kotlin-multiplatform","kotlin-native"],"created_at":"2024-08-01T09:00:54.348Z","updated_at":"2025-04-02T03:31:33.400Z","avatar_url":"https://github.com/Foso.png","language":"Kotlin","funding_links":[],"categories":["Libraries","Recently Updated","Logging"],"sub_categories":["Debug","[Oct 28, 2024](/content/2024/10/28/README.md)","SQL"],"readme":"\n\u003ch1 align=\"center\"\u003e:pencil2: Cabret :pencil2:\u003c/h1\u003e\n\n[![jCenter](https://img.shields.io/badge/Apache-2.0-green.svg\n)](https://github.com/Foso/DebugLog/blob/master/LICENSE)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n[![jCenter](https://img.shields.io/badge/Kotlin-1.4.21-green.svg\n)](https://github.com/Foso/Sheasy/blob/master/LICENSE)\n\n\n\n## Introduction 🙋‍♂️ 🙋‍\n\nThis is an Kotlin Library that enables Annotation-triggered method call logging for Kotlin Multiplatform. Inspired by [Hugo](https://github.com/JakeWharton/hugo), [Hunter-Debug](https://github.com/Leaking/Hunter/blob/master/README_hunter_debug.md) and the [blog posts](https://blog.bnorm.dev/) by [bnorm](https://github.com/bnorm) .\n\nSimply add **@DebugLog** to your methods and it will automatically log all arguments that are passed to the function the return value and the time the function needed to excecute.\n\nWhen the following function gets called:\n\n```kotlin\n@DebugLog\nfun exampleFun(\n    first: String,\n    last: String,\n    age: Int = 31,\n    isLoggedIn: Boolean = false\n): String = \"$first $last\"\n\nfun main(){\n  exampleFun(\"Jens\",\"Klingenberg\")\n}\n```\n\nIt will automatically log:\n```kotlin\nExample -\u003e exampleFun( first= Jens, last= Klingenberg, age= 31, isLoggedIn= false)\nExample \u003c- exampleFun() [2.63ms] =  Jens Klingenberg\n```\n\n### Show some :heart: and star the repo to support the project\n\n[![GitHub stars](https://img.shields.io/github/stars/Foso/Cabret-Log.svg?style=social\u0026label=Star)](https://github.com/Foso/Cabret-Log) [![GitHub forks](https://img.shields.io/github/forks/Foso/Cabret-Log.svg?style=social\u0026label=Fork)](https://github.com/Foso/Cabret-Log/fork) [![GitHub watchers](https://img.shields.io/github/watchers/Foso/Cabret-Log.svg?style=social\u0026label=Watch)](https://github.com/Foso/Cabret-Log) [![Twitter Follow](https://img.shields.io/twitter/follow/jklingenberg_.svg?style=social)](https://twitter.com/jklingenberg_)\n\n## Setup\n\u003e You can take a look at [DemoProject](https://github.com/Foso/Cabret-Log/tree/master/CabretDemo) as an example\n\n### 1) Gradle Plugin\n\nAdd the dependency to your buildscript\n\n```groovy\nbuildscript {\n    repositories {\n        mavenCentral()\n    }\n\n    dependencies {\n        classpath \"de.jensklingenberg.cabret:cabret-gradle:1.0.3\"\n    }\n}\n\n```\n#### 2) Apply the plugin\n\n\nKotlin DSL:\n\n```kotlin\nplugins {\n     id(\"de.jensklingenberg.cabret\")\n}\n\nconfigure\u003cde.jensklingenberg.gradle.CabretGradleExtension\u003e {\n    enabled = true\n    version = \"1.0.4\"\n}\n```       \n\nGroovy DSL:\n\n```gradle\nplugins {\n    id 'de.jensklingenberg.cabret'\n}\n\ncabret {\n    enabled = true\n    version = 1.0.4\n}\n```\n\nThe plugin will only be active when **enabled** is set to **true**\n\n### 3) Log Library\nTo be able to use the DebugLog annotation, you also need add the dependecies on cabret-log.\n\n#### Multiplatform (Common, JS, Native)\n\nYou can add dependency to the right to the common source set:\n```gradle\ncommonMain {\n    dependencies {\n        implementation \"de.jensklingenberg.cabret:cabret-log:1.0.4\"\n    }\n}\n```\n\n#### Platform-specific \nYou can also add platform-specific dependecies\n\n```gradle\nsourceSets {\n    jvmMain {\n            dependencies {\n                 implementation \"de.jensklingenberg.cabret:cabret-log-jvm:1.0.4\"\n            }\n   }\n}\n```\n\nHere's a list of all available targets:\n```gradle\ndef cabretVersion = \"1.0.4\"\n\nimplementation \"de.jensklingenberg.cabret:cabret-log-jvm:$cabretVersion\"\nimplementation \"de.jensklingenberg.cabret:cabret-log-js:$cabretVersion\"\nimplementation \"de.jensklingenberg.cabret:cabret-log-android:$cabretVersion\"\nimplementation \"de.jensklingenberg.cabret:cabret-log-iosx64:$cabretVersion\"\nimplementation \"de.jensklingenberg.cabret:cabret-log-iosarm64:$cabretVersion\"\nimplementation \"de.jensklingenberg.cabret:cabret-log-linux:$cabretVersion\"\nimplementation \"de.jensklingenberg.cabret:cabret-log-macos:$cabretVersion\"\nimplementation \"de.jensklingenberg.cabret:cabret-log-watchosarm32:$cabretVersion\"\nimplementation \"de.jensklingenberg.cabret:cabret-log-watchosarm64:$cabretVersion\"\nimplementation \"de.jensklingenberg.cabret:cabret-log-tvosarm32:$cabretVersion\"\nimplementation \"de.jensklingenberg.cabret:cabret-log-tvosarm64:$cabretVersion\"\n\n\n```\n\n### 4) Enable IR\nCabret is using a Kotlin Compiler Plugin that is using the IR Backend. For Native targets it's already enabled, but you need to activate it in your build.gradle for Kotlin JVM/JS\n\n##### Kotlin/JVM\n```kotlin\ntasks.withType\u003cKotlinCompile\u003e().configureEach {\n  kotlinOptions {\n    useIR = true\n  }\n}\n```\n\n##### Kotlin/JS\n```kotlin\ntarget {\n  js(IR) {\n  }\n}\n```\n\n## Logging\n\n### Tag\n\n```kotlin\n@DebugLog( tag = \"MyTag\")\n```\n\nYou can add a tag to the DebugLog annotation under which you can find your logged data. When you don't add a custom tag, Cabret will use the file name for top level function and the class name for class functions as the tag.\n\n### LogLevel\n```kotlin\n@DebugLog(logLevel = Cabret.LogLevel.ERROR)\n```\n\nYou can set a LogLevel to the DebugLog Annotation. You can choose between VERBOSE, DEBUG, INFO, WARN or ERROR. By default DEBUG is selected. \n\n### Custom Logger\nBy default Cabret will log the data with printLn() or on Android with android.util.Log and the selected LogLevel. E.g. LogLevel.ERROR will be logged with Log.e(), LogLevel.INFO will be logged with Log.i(), etc. \n\nYou can add your own Logger. All you need to do is to add your object of Cabret.Logger to Cabret.addLogger() somewhere at the beginning of your programm.\n\n```kotlin\nCabret.addLogger(object : Cabret.Logger {\n            override fun log(data: LogData) {\n                //Add your logger here\n                println(data.tag + \" \" + data.msg)\n            }\n})\n```\n\n### 👷 Project Structure\n\n*  \u003ckbd\u003ecabret-compiler-plugin\u003c/kbd\u003e - This module contains the Kotlin Compiler Plugin for JVM/JS targets\n*  \u003ckbd\u003ecabret-compiler-native-plugin\u003c/kbd\u003e - This module contains the Kotlin Compiler Plugin for native targets\n*  \u003ckbd\u003ecabret-compiler-runtime\u003c/kbd\u003e - This module contains the shared Kotlin Compiler Plugin Logic for JVM/JS/Native compiler\n*  \u003ckbd\u003ecabret-gradle\u003c/kbd\u003e - This module contains the gradle plugin which triggers the two compiler plugins\n*  \u003ckbd\u003ecabret-log\u003c/kbd\u003e - A Kotlin Multiplatform project with the DebugLog annotation and the default loggers\n*  \u003ckbd\u003eDemoProject\u003c/kbd\u003e - A Kotlin Multiplatform project that is using the debuglog compiler plugin\n\n## ✍️ Feedback\n\nFeel free to send feedback on [Twitter](https://twitter.com/jklingenberg_) or [file an issue](https://github.com/foso/Cabret-Log/issues/new). Feature requests are always welcome.\n\n## 📜 License\n\n-------\n\nThis project is licensed under Apache License, Version 2.0\n\n    Copyright 2020 Jens Klingenberg\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFoso%2FCabret-Log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFoso%2FCabret-Log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFoso%2FCabret-Log/lists"}