{"id":26227615,"url":"https://github.com/bolteu/kalev","last_synced_at":"2025-04-19T16:19:07.435Z","repository":{"id":40248772,"uuid":"257891146","full_name":"bolteu/kalev","owner":"bolteu","description":"Structured logging for JVM.","archived":false,"fork":false,"pushed_at":"2022-05-18T08:36:24.000Z","size":107,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":10,"default_branch":"master","last_synced_at":"2023-07-03T15:08:07.693Z","etag":null,"topics":["android","kotlin","logging"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bolteu.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-04-22T12:12:23.000Z","updated_at":"2023-02-28T11:16:57.000Z","dependencies_parsed_at":"2022-08-24T14:33:38.368Z","dependency_job_id":null,"html_url":"https://github.com/bolteu/kalev","commit_stats":null,"previous_names":[],"tags_count":3,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolteu%2Fkalev","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolteu%2Fkalev/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolteu%2Fkalev/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolteu%2Fkalev/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bolteu","download_url":"https://codeload.github.com/bolteu/kalev/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243285620,"owners_count":20266849,"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","logging"],"created_at":"2025-03-12T20:18:10.163Z","updated_at":"2025-03-12T20:18:10.806Z","avatar_url":"https://github.com/bolteu.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kalev\n\n![Maven Central](https://img.shields.io/maven-central/v/eu.bolt/kalev?style=plastic)\n\nKalev is a structured logger for JVM (Java, Kotlin etc)\n\nThe idea of `Kalev` is pretty similar to `Timber`. Library provides `Kalevipoeg` interface with which you may implement various behaviour for log entries reaction.\n\n## Packages\n\n`kalev-lib` provides pure JVM implementation. Doesn't contains any implementation of `Kalevipoeg`  \n`kalev-android` contains bridge between Kalev and Android's log system. `PrintPoeg` format log entry as JSON string and print it to LogCat.  \n`kalev-okhttp` provide interceptor for `okhttp` to log network requests in Kalev-way\n\n\n## Usage\n\nTwo easy steps:\n\n1. Add any `Kalevipoeg` instances you want on application start. In Android application `onCreate` is a most suitable place\n2. Call Kalev's static methods everywhere throughout your app.\n\nCheck full Android sample at `sample` dir\n\n### Fields\n\nKalev encourages careful, structured logging through logging fields instead of long, unparseable error messages. For example, instead of: `Log.e(\"Failed to send event %s to topic %s with key %d\", userEvent, selectedTopic, eventKey)`, you should log the much more discoverable:\n\n```kotlin\nKalev.with(\"event\", userEvent)\n    .with(\"key\", eventKey)\n    .with(\"topic\", selectedTopic)\n    .e(\"Failed to send event\")\n```\n\nNote, that `with` call is optional\n\n### Level logging\n\nKalev provides 5 levels of logs: verbose, debug, info, warning and error.\n\n```kotlin\nKalev.v(\"Fragment created\")\nKalev.v(throwable, \"Fragment wasn't added\")\n\nKalev.d(\"User logged in\")\nKalev.d(throwable, \"User error\")\n\nKalev.i(\"Added item to bucket\")\nKalev.i(throwable, \"Busket is full\")\n\nKalev.w(\"Paying for order\")\nKalev.w(throwable, \"Failed to pay\")\n\nKalev.e(\"Smth happens\")\nKalev.e(throwable, \"Smth happened\")\n```\n\n### Entries\n\nBesides the fields added with `with` some fields are automatically added to all logging events:\n\n`severity` The logging level. E.g. `i`.  \n`timestamp` The timestamp when the entry was created.  \n`message` The logging message passed to {v, d, i, w, e} after the `with` call. E.g. `Failed to send event.`\n\n### Network Logging\n\nAdd `LoggingInterceptor` to your `OkHttpClient` to log network requests in Kalev-way.\nExamples of network logs:\n\n[http://httpbin.org/get?id=42](http://httpbin.org/get?id=42)  \n```json\n{\n  \"message\": \"network\",\n  \"method\": \"GET\",\n  \"path\": \"\\/get\",\n  \"id\": \"42\",\n  \"response.code\": 200,\n  \"response.body\": {\n    \"args\": {\n      \"id\": \"42\"\n    },\n    \"headers\": {\n      \"Accept-Encoding\": \"gzip\",\n      \"Content-Type\": \"application\\/json\",\n      \"Host\": \"httpbin.org\",\n      \"User-Agent\": \"okhttp\\/3.12.12\",\n      \"X-Amzn-Trace-Id\": \"Root=1-5ed772b8-71eaec363ea2adcca9201200\"\n    },\n    \"url\": \"https:\\/\\/httpbin.org\\/get?id=42\"\n  }\n}\n```\n\n[http://httpbin.org/unknown](http://httpbin.org/unknown)\n```json\n{\n  \"message\": \"network\",\n  \"method\": \"GET\",\n  \"path\": \"\\/unknown\",\n  \"id\": \"42\",\n  \"response.code\": 404,\n  \"response.body\": \"\u003c!DOCTYPE HTML PUBLIC \\\"-\\/\\/W3C\\/\\/DTD HTML 3.2 Final\\/\\/EN\\\"\u003e\\n\u003ctitle\u003e404 Not Found\u003c\\/title\u003e\\n\u003ch1\u003eNot Found\u003c\\/h1\u003e\\n\u003cp\u003eThe requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.\u003c\\/p\u003e\\n\"\n}\n```\n\n### FastLog\nKalev creates new object for every log entry which may abuse performance in case of stream of entries. You can go around of this issue with FastLog. \n\n#### FastLog usage\nThere is `FastLog` interface which describes fast logger.  \n`kalev-lib` provides `SystemFastLog` implementation which prints messages to standard output stream   \n`kalev-android` provides `AndroidFastLog` implementation which prints messages to Android's LogCat\n##### Initialisation:   \n`Kalev.fastLog = AndroidFastLog()`  \n##### Logging\n`Kalev.fastLog?.v(\"Activity created\")`\n\n## Gradle\nAdd this to your dependencies block.\n```\nimplementation 'eu.bolt:kalev:$latest'\n```\n\nTo use an android extension use this dependency instead:\n```\nimplementation 'eu.bolt:kalev-android:$latest'\n```\n\nKalev-okhttp package:\n```\nimplementation 'eu.bolt:kalev-okhttp:$latest'\n```\n\n## Naming\n\nKaleva - also known as Kalevi or Kalev - and his sons are important heroic figures in Estonian, Finnish and Karelian mythology. [Wiki](https://en.wikipedia.org/wiki/Kalevi_(mythology))\n\n## License\n```\nMIT License\n\nCopyright (c) 2020 Bolt Technologies OÜ\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbolteu%2Fkalev","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbolteu%2Fkalev","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbolteu%2Fkalev/lists"}