{"id":13790016,"url":"https://github.com/jupf/staticlog","last_synced_at":"2025-05-12T07:31:19.315Z","repository":{"id":57733758,"uuid":"47218381","full_name":"jupf/staticlog","owner":"jupf","description":"StaticLog - super lightweight static logging for Kotlin, Java and Android","archived":false,"fork":false,"pushed_at":"2017-11-27T20:34:17.000Z","size":178,"stargazers_count":28,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-18T04:35:34.343Z","etag":null,"topics":["android","java","kotlin","logger"],"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/jupf.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":"2015-12-01T21:24:37.000Z","updated_at":"2022-10-03T16:43:08.000Z","dependencies_parsed_at":"2022-08-24T07:11:10.546Z","dependency_job_id":null,"html_url":"https://github.com/jupf/staticlog","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupf%2Fstaticlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupf%2Fstaticlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupf%2Fstaticlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupf%2Fstaticlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jupf","download_url":"https://codeload.github.com/jupf/staticlog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253695098,"owners_count":21948812,"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","java","kotlin","logger"],"created_at":"2024-08-03T22:00:35.969Z","updated_at":"2025-05-12T07:31:18.891Z","avatar_url":"https://github.com/jupf.png","language":"Kotlin","funding_links":[],"categories":["\u003ca name=\"utility\"\u003e\u003c/a\u003eUtility \u003csup\u003e[Back ⇈](#contents)\u003c/sup\u003e"],"sub_categories":[],"readme":"# StaticLog  \n[![Kotlin](https://img.shields.io/badge/Kotlin-1.1.61-blue.svg?style=flat) ](https://kotlinlang.org/)  [![license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat) ](https://github.com/jupf/staticlog/blob/master/LICENSE) [![Dependency Status](https://www.versioneye.com/user/projects/56cc29b518b2710403dfed86/badge.svg)](https://www.versioneye.com/user/projects/56cc29b518b2710403dfed86) [ ![Download](https://api.bintray.com/packages/jupf/maven/StaticLog/images/download.svg?style=flat) ](https://bintray.com/jupf/maven/StaticLog/_latestVersion)  \n  \nStaticLog is a super lightweight logging library implemented in pure Kotlin ([https://kotlinlang.org](https://kotlinlang.org/)). It is designed to be used in Kotlin, Java and Android.  \nIt is for formatting standard output comfortably without the need to construct a Logger object. But it's also no problem to create one.  \n  \nThis is an example output in [IntelliJ IDEA](http://www.jetbrains.com/idea/)\n![example output](https://drive.google.com/uc?export=view\u0026id=0B3Hm3TAXNccQVnRNODRDWDg2eFk)\nYes, the occurrence of the log message is clickable!  \n\n## Table of Contents\n- [StaticLog](#staticlog)\n\t- [Getting Started](#getting-started)\n\t\t- [Gradle / Maven](#gradle--maven)\n\t- [StaticLog in Kotlin](#staticlog-in-kotlin)\n\t\t- [Logging in Kotlin](#logging-in-kotlin)\n\t\t- [Formatting Output in Kotlin](#formatting-output-in-kotlin)\n        - [Tag Filtering in Kotlin](#tag-filtering-in-kotlin)\n\t\t- [Log instances in Kotlin](#log-instances-in-kotlin)\n\t\t- [FormatBuilders in Kotlin](#formatbuilders-in-kotlin)\n\t\t- [Custom Printers in Kotlin](#custom-printers-in-kotlin)\n\t- [StaticLog in Java](#staticlog-in-java)\n\t\t- [Logging in Java](#logging-in-java)\n\t\t- [Formatting Output in Java](#formatting-output-in-java)\n\t\t- [Tag Filtering in Java](#tag-filtering-in-java)\n\t\t- [Log instances in Java](#log-instances-in-java)\n\t\t- [FormatBuilders in Java](#formatbuilders-in-java)\n\t\t- [Custom Printers in Java](#custom-printers-in-java)\n\t- [StaticLog in Android](#staticlog-in-android)\n\n## Getting Started  \n\nThe source/target compatibility is Java 1.6.  \nThis library is uploaded to jCenter and Maven Central.\n\n### Gradle / Maven  \n\n```gradle\ndependencies {\n    compile 'io.github.jupf.staticlog:staticlog:2.2.0'\n}\n```\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.jupf.staticlog\u003c/groupId\u003e\n    \u003cartifactId\u003estaticlog\u003c/artifactId\u003e\n    \u003cversion\u003e2.1.9\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nIf you ___dont___ have the Kotlin runtime already present in your project, use the following dependency. \n\n```gradle\ndependencies {\n    compile 'io.github.jupf.staticlog:staticlog-java:2.2.0'\n}\n```\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.jupf.staticlog\u003c/groupId\u003e\n    \u003cartifactId\u003estaticlog-java\u003c/artifactId\u003e\n    \u003cversion\u003e2.1.9\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n\n## StaticLog in Kotlin\nYou can find the example source code [here](https://github.com/jupf/staticlog/blob/master/src/main/kotlin/example/example.kt).  \n\n### Logging in Kotlin  \n\nLogging with StaticLog in Kotlin is as easy as it gets:  \n\n```kotlin\nLog.info(\"This is an info message\")\nLog.debug(\"This is a debug message\")\nLog.warn(\"This is a warning message\",\"WithACustomTag\")\nLog.error(\"This is an error message with an additional Exception for output\", \"AndACustomTag\", exception )\n\nLog.logLevel = LogLevel.WARN\nLog.info(\"This message will not be shown\")\n```\n\n### Formatting Output in Kotlin  \n\nTo define an output format for StaticLog in Kotlin is very easy. It uses a mix from builders and function call syntax.  \nThis defines for example the default format:  \n\n```kotlin\nLog.newFormat {\n    line(date(\"yyyy-MM-dd HH:mm:ss\"), space, level, text(\"/\"), tag, space(2), message, space(2), occurrence)\n}\n```\n\nYou can even define multiple lines and indent them:  \n\n```kotlin\nLog.newFormat {\n    line(date(\"yyyy-MM-dd HH:mm:ss\"), space, level, text(\"/\"), tag, space(2), occurrence)\n    indent {\n        line(message)\n    }\n}\n```\n\n### Tag Filtering in Kotlin  \n\nIt is possible to filter the output for a specific tag. This is rather easy, just provide the tag:  \n\n```kotlin\nLog.filterTag = \"filterTag\"\nLog.info(\"This log will be filtered out\", \"otherTag\")\nLog.info(\"This log has the right tag\", \"filterTag\")\n```\n\nDeleting a tag filter is just as easy:  \n\n```kotlin\nLog.deleteTagFilter()\n```\n\n### Log instances in Kotlin  \n\nIf you need another log instance you can create one very easy. It can have an own format and log level:  \n\n```kotlin\nval logger = Log.kotlinInstance()\nlogger.debug(\"This message is from an individual logger instance\")\n```\n\nThe interface of individual log instances is exactly the same as the interface for the static Log class.  \n\n### FormatBuilders in Kotlin  \n\nHere are all possible FormatBuilders: \n\n| FormatBuilder   |     Output      |\n|:----------------:|:---------------:|\n| date(Pattern)    | Prints the date in the given pattern  \u003cbr\u003e(The pattern is defined in [SimpleDateFormat](http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html))\u003c/br\u003e  |\n| epoch            | Prints the current time in milliseconds  |\n| level            | Prints the log level |\n| tag              | Prints the log tag \u003cbr\u003e(If none was provided to the logging function, \u003cbr\u003eit defaults to the class name the message was logged from.)\u003c/br\u003e\u003c/br\u003e |\n| message          | Prints the log message |\n| occurrence       | Prints the origin of the logging (In Eclipse and IntelliJ clickable!)|\n| space            | Prints 1 space  |\n| space(X: Integer)| Prints X spaces    |\n| tab              | Prints 1 tab |\n| tab(X: Integer)  | Prints X tabs |\n| text(S: String)  | Prints the String S |\n\n### Custom Printers in Kotlin\n\ntbd\n\n## StaticLog in Java  \n\nYou can find the example source code [here](https://github.com/jupf/staticlog/blob/master/src/main/java/example/Example.java).  \n\n### Logging in Java  \n\nLogging with StaticLog in Kotlin is as easy as it gets:  \n\n```java\nLog.info(\"This is an info message\");\nLog.debug(\"This is a debug message\");\nLog.warn(\"This is a warning message\",\"WithACustomTag\");\nLog.error(\"This is an error message with an additional Exception for output\", \"AndACustomTag\", exception );\n\nLog.setLogLevel(LogLevel.WARN);\nLog.info(\"This message will not be shown\");\n```\n\n### Formatting Output in Java  \n\nTo define an output format for StaticLog in Java is very easy.  \nThis defines for example the default format:  \n\n```java\nimport static de.jupf.staticlog.Log.FormatOperations.*;\n\n...\n\nLogFormat format = Log.newFormat();\nformat.line(date(\"yyyy-MM-dd HH:mm:ss\"), space(1), level(), text(\"/\"), tag(), space(2), message(), space(2), occurrence());\n```\n\nYou can even define multiple lines and indent them:  \n\n```java\nLogFormat format = Log.newFormat();\nformat.line(date(\"yyyy-MM-dd HH:mm:ss\"), space(1), level(), text(\"/\"), tag(), space(2), occurrence());\nformat.indent(line(message()));\n```\n\n### Tag Filtering in Java  \n\nIt is possible to filter the output for a specific tag. This is rather easy, just provide the tag:  \n\n```java\nLog.setTagFilter(\"filterTag\");\nLog.info(\"This log will be filtered out\", \"otherTag\");\nLog.info(\"This log has the right tag\", \"filterTag\");\n```\n\nDeleting a tag filter is just as easy:  \n\n```java\nLog.deleteTagFilter();\n```\n\n### Log instances in Java  \n\nIf you need another log instance you can create one very easy. It can have an own log level and format:  \n\n```Java\nLogger logger = Log.javaInstance();\nlogger.debug(\"This message is from an individual logger instance\");\n```\n\nThe interface of individual log instances is exactly the same as the interface for the static Log class.  \n\n### FormatBuilders in Java  \n\nHere are all possible FormatBuilders:\n\n| FormatBuilder   |     Output      |\n|:----------------:|:---------------:|\n| date(Pattern)    | Prints the date in the given pattern  \u003cbr\u003e(The pattern is defined in [SimpleDateFormat](http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html))\u003c/br\u003e  |\n| epoch()          | Prints the current time in milliseconds  |\n| level()          | Prints the log level |\n| tag()            | Prints the log tag \u003cbr\u003e(If none was provided to the logging function, \u003cbr\u003eit defaults to the class name the message was logged from.)\u003c/br\u003e\u003c/br\u003e |\n| message()        | Prints the log message |\n| occurrence()     | Prints the origin of the logging (In Eclipse and IntelliJ clickable!)|\n| space(X: Integer)| Prints X spaces    |\n| tab(X: Integer)  | Prints X tabs |\n| text(S: String)  | Prints the String S |\n\n### Custom Printers in Java\n\ntbd\n\n## StaticLog in Android  \n\nStaticLog automatically detects Android VMs and switches its output to the Android logger.  \nThe default format for Android is defined like this:  \n\n```java\nformat.line(message(), space(2), occurrence());\n```\n\nThe tag is forwarded to the Android logger. If none is provided, it defaults to the class name the log was printed from.  \nFor further questions look at [StaticLog in Java](#staticlog-in-java)  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupf%2Fstaticlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjupf%2Fstaticlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupf%2Fstaticlog/lists"}