{"id":13605332,"url":"https://github.com/Chesire/LifecykleLog","last_synced_at":"2025-04-12T05:32:35.380Z","repository":{"id":35844764,"uuid":"177210022","full_name":"Chesire/LifecykleLog","owner":"Chesire","description":"Android library to log out Activity and Fragment lifecycle methods","archived":false,"fork":false,"pushed_at":"2023-03-15T09:56:46.000Z","size":396,"stargazers_count":22,"open_issues_count":14,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-02T19:37:12.052Z","etag":null,"topics":["activity-lifecycle","android","android-activity","android-activity-lifecycle","android-architecture","android-fragments","android-library","android-lifecycle","android-logging","annotation","fragment-lifecycle","hacktoberfest","kotlin","kotlin-android","lifecycle-methods"],"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/Chesire.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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":"2019-03-22T21:14:00.000Z","updated_at":"2023-09-10T23:40:07.000Z","dependencies_parsed_at":"2024-01-16T23:30:19.622Z","dependency_job_id":"aac2ac7e-0fb7-4f73-8de8-8b5408f4a630","html_url":"https://github.com/Chesire/LifecykleLog","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/Chesire%2FLifecykleLog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chesire%2FLifecykleLog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chesire%2FLifecykleLog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Chesire%2FLifecykleLog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Chesire","download_url":"https://codeload.github.com/Chesire/LifecykleLog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223497744,"owners_count":17155199,"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":["activity-lifecycle","android","android-activity","android-activity-lifecycle","android-architecture","android-fragments","android-library","android-lifecycle","android-logging","annotation","fragment-lifecycle","hacktoberfest","kotlin","kotlin-android","lifecycle-methods"],"created_at":"2024-08-01T19:00:57.486Z","updated_at":"2024-11-07T10:30:25.983Z","avatar_url":"https://github.com/Chesire.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"# LifecykleLog  \n\n\u003e Library to easily log out Android lifecycle methods for Activities and Fragments.\n\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-LifecykleLog-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/7752)\n![Android CI](https://github.com/Chesire/LifecykleLog/workflows/Android%20CI/badge.svg)\n[![codecov](https://codecov.io/gh/Chesire/LifecykleLog/branch/master/graph/badge.svg)](https://codecov.io/gh/Chesire/LifecykleLog)\n\n## Installation\n\nGradle:\nMake sure you have JitPack as a source\n```groovy\nmaven { url 'https://jitpack.io' }\n```\nadd the following line to your `build.gradle`, with version being the latest tag.\n\n```groovy\nimplementation 'com.github.chesire:lifecyklelog:{version}'\n```\n\n## Usage example\n\nInitialize in your application class.\n\n```kotlin\nclass ApplicationOverride : Application() {\n    override fun onCreate() {\n        super.onCreate()\n        LifecykleLog.initialize(this)\n    }\n}\n```\n\nAdd the `@LogLifecykle` annotation to the Activity or Fragment that the\nlifecycle methods should be logged for.\n\n```kotlin\n@LogLifecykle\nclass MainActivity : AppCompatActivity() { ...\n\n@LogLifecykle\nclass MainFragment : Fragment() { ...\n```\n\nThen lifecycle events will be logged out in logcat.\n\n```text\nD/Lifecykle: MainActivity ⇀ onStart\nD/Lifecykle: MainFragment ⇀ onAttach\nD/Lifecykle: MainFragment ⇀ onCreate\nD/Lifecykle: MainFragment ⇀ onCreateView\nD/Lifecykle: MainFragment ⇀ onActivityCreated\nD/Lifecykle: MainFragment ⇀ onStart\nD/Lifecykle: MainActivity ⇀ onResume\nD/Lifecykle: MainFragment ⇀ onResume\nD/Lifecykle: MainActivity ⇀ onPause\nD/Lifecykle: MainFragment ⇀ onPause\nD/Lifecykle: MainActivity ⇀ onStop\nD/Lifecykle: MainFragment ⇀ onStop\n```\n\n## Configuration\n\n### Logging mechanism\n\nBy default LogLifecykle will output to `Log.d` with a tag of `Lifecykle`, to\noverride this behaviour pass an implementation into the\n`LifecykleLog.logHandler`.\n\n```kotlin\nLifecykleLog.logHandler = LogHandler { clazz, lifecycleEvent, bundle -\u003e\n    Log.e(clazz, lifecycleEvent) \n}\n```\n\nThis can allow you to use other logging frameworks such as Timber.\n\n```kotlin\nLifecykleLog.logHandler = LogHandler { clazz, lifecycleEvent, bundle -\u003e\n    Timber.i(\"$clazz -\u003e $lifecycleEvent - $bundle\")\n}\n```\n\nFor lifecycle methods which pass a bundle along, it will automatically be pushed\nthrough the LogHandler. In instances where there is no bundle, or it is empty,\nthen the value will simply be \"null\".\n\n### Lifecycle methods\n\nTo customise which lifecycle methods are logged out, an array of the\n`LifecycleEvent` enum can be passed into  `LifecykleLog.logEvents`, this can\nalso be done with the `@LogLifecykle` annotation.\n\n```kotlin\nLifecykleLog.logEvents = arrayOf(\n    LifecycleEvent.ON_CREATE, \n    LifecycleEvent.ON_DESTROY\n)\n\n@LogLifecykle(overrideLogEvents = [LifecycleEvent.ON_START])\nclass MainActivity : AppCompatActivity() {\n\n@LogLifecykle(overrideLogEvents = [LifecycleEvent.ON_ACTIVITY_CREATED, LifecycleEvent.ON_ATTACH])\nclass MainFragment : Fragment() {\n```\n\nIf `logEvents` is provided to the `LifecykleLog` then it will override the\ndefaults.  \nIf `overrideLogEvents` is provided on the annotation, **only** the methods that\nare provided in this will be logged out.\n\n### Class name\n\nTo customise the class name that is logged out, a new name can be provided to\nthe annotation.\n\n```kotlin\n@LogLifecykle(className = \"MainActivity\")\nclass MainActivity : AppCompatActivity() {\n\n@LogLifecykle(className = \"MaybeMainFragment\")\nclass MainFragment : Fragment() {\n```\n\nThis can be useful if ProGuard strips out the class names and you really need to\nsee them in the logs. By default the name will be pulled from the objects\n`class.java.simpleName`.\n\n### Remove Annotation\n\nIf you want to perform logging of *ALL* Activities and Fragments, without\nneeding to add the annotation to them, then the configuration option\n`requireAnnotation` can be set to `false`.\n\n```kotlin\nLifecykleLog.requireAnnotation = false\n```\n\nThis will ignore any annotations that are currently set, and perform logging for\nevery Activity and Fragment on the lifecycle events defined in\n`LifecykleLog.logEvents`.\n\n_For more examples and usage, please refer to the\n[sample](https://github.com/Chesire/LifecykleLog/tree/master/lifecyklelog-sample)._\n\n## Contributing\n\nPlease read\n[CONTRIBUTING.md](https://github.com/Chesire/LifecykleLog/blob/master/CONTRIBUTING.md)\nfor details on how to contribute.\n\n## License\n\nApache 2.0 - See\n[LICENSE](https://github.com/Chesire/LifecykleLog/blob/master/LICENSE) for more\ninformation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FChesire%2FLifecykleLog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FChesire%2FLifecykleLog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FChesire%2FLifecykleLog/lists"}