{"id":13516431,"url":"https://github.com/ajalt/timberkt","last_synced_at":"2025-04-09T22:18:48.353Z","repository":{"id":144517819,"uuid":"62193369","full_name":"ajalt/timberkt","owner":"ajalt","description":"Easy Android logging with Kotlin and Timber","archived":false,"fork":false,"pushed_at":"2019-05-09T15:49:44.000Z","size":167,"stargazers_count":206,"open_issues_count":2,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-09T22:18:43.025Z","etag":null,"topics":["android","kotlin","kotlin-extensions","logging"],"latest_commit_sha":null,"homepage":null,"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/ajalt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-06-29T03:42:05.000Z","updated_at":"2025-03-23T14:13:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"98aa9a0a-2cf8-4f46-a7f4-f9b32d79b581","html_url":"https://github.com/ajalt/timberkt","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajalt%2Ftimberkt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajalt%2Ftimberkt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajalt%2Ftimberkt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajalt%2Ftimberkt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajalt","download_url":"https://codeload.github.com/ajalt/timberkt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248119285,"owners_count":21050755,"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":["android","kotlin","kotlin-extensions","logging"],"created_at":"2024-08-01T05:01:22.217Z","updated_at":"2025-04-09T22:18:48.332Z","avatar_url":"https://github.com/ajalt.png","language":"Kotlin","funding_links":[],"categories":["开源库","Kotlin"],"sub_categories":["日志"],"readme":"# Kotlin logging extensions for Timber\n\nJake Wharton's [Timber](https://github.com/JakeWharton/timber) library is great. It's a Java library with an API that works well for Java, but that isn't as idiomatic when used in Kotlin. \n\nThis library builds on Timber with an API that's easier to use from Kotlin. Instead of using formatting parameters, you pass a lambda that is only evaluated if the message is logged.\n\n## Usage\n\n1. Configure any `Tree` instances in your Application's `onCreate`, the same way as with plain [Timber](https://github.com/JakeWharton/timber#usage).\n2. Call the extension functions from anywhere in your code.\n\n```kotlin\n// Standard timber\nTimber.d(\"%d %s\", intVar + 3, stringFun())\n\n// Kotlin extensions\nTimber.d { \"${intVar + 3} ${stringFun()}\" }\n// or\nd { \"${intVar + 3} ${stringFun()}\" }\n```\n\nThe same message and tags will be logged in all three cases. \n\nThe Kotlin extensions have the advantage of being more convenient to write, and are also more performant in some circumstances. The passed block is only evaluated if the message is logged, and even if the message is logged to multiple trees, the block is only evaluated once. All extension methods are inlined, so there is no method count penalty to using this library.\n\nLogging exception objects works the same way:\n\n```kotlin\n// Standard timber\nTimber.e(exception, \"%d exceptions\", errorCount)\n\n// Kotlin extensions\nTimber.e(exception) { \"$errorCount exceptions\" }\n// or\ne(exception) { \"$errorCount exceptions\" }\n```\n\n## What about Timber's custom lint checks?\n\nTimber comes with half a dozen lint checks that help you spot incorrect usage of the log calls. \n\nWith the exception of long custom tags, none of the errors those checks look for are possible with this library. You can perform arbitrary code inside of the lambdas passed to the log extensions, and there's no risk of performance problems in your release code since the blocks won't be evaluated unless the messages are printed.\n\n## Download\n\nThe Kotlin extensions for Timber are distributed with Maven Central, \n[JCenter](https://bintray.com/ajalt/maven/timberkt) and\n[JitPack](https://jitpack.io/#ajalt/timberkt/1.5.1).\n\n```groovy\nimplementation 'com.github.ajalt:timberkt:1.5.1'\n```\n\n## Documentation\n\n[The documentation is hosted online here](https://jitpack.io/com/github/ajalt/timberkt/1.5.1/javadoc/timberkt/com.github.ajalt.timberkt/index.html).\n\n## License\n\n```\nCopyright 2017-2018 AJ Alt\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajalt%2Ftimberkt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajalt%2Ftimberkt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajalt%2Ftimberkt/lists"}