ProductPromotion
Logo

Kotlin

made by https://0x3d.site

GitHub - jupf/staticlog: StaticLog - super lightweight static logging for Kotlin, Java and Android
StaticLog - super lightweight static logging for Kotlin, Java and Android - jupf/staticlog
Visit Site

GitHub - jupf/staticlog: StaticLog - super lightweight static logging for Kotlin, Java and Android

GitHub - jupf/staticlog: StaticLog - super lightweight static logging for Kotlin, Java and Android

StaticLog

Kotlin license Dependency Status Download

StaticLog is a super lightweight logging library implemented in pure Kotlin (https://kotlinlang.org). It is designed to be used in Kotlin, Java and Android.
It is for formatting standard output comfortably without the need to construct a Logger object. But it's also no problem to create one.

This is an example output in IntelliJ IDEA example output Yes, the occurrence of the log message is clickable!

Table of Contents

Getting Started

The source/target compatibility is Java 1.6.
This library is uploaded to jCenter and Maven Central.

Gradle / Maven

dependencies {
    compile 'io.github.jupf.staticlog:staticlog:2.2.0'
}
<dependency>
    <groupId>io.github.jupf.staticlog</groupId>
    <artifactId>staticlog</artifactId>
    <version>2.1.9</version>
</dependency>

If you dont have the Kotlin runtime already present in your project, use the following dependency.

dependencies {
    compile 'io.github.jupf.staticlog:staticlog-java:2.2.0'
}
<dependency>
    <groupId>io.github.jupf.staticlog</groupId>
    <artifactId>staticlog-java</artifactId>
    <version>2.1.9</version>
</dependency>

StaticLog in Kotlin

You can find the example source code here.

Logging in Kotlin

Logging with StaticLog in Kotlin is as easy as it gets:

Log.info("This is an info message")
Log.debug("This is a debug message")
Log.warn("This is a warning message","WithACustomTag")
Log.error("This is an error message with an additional Exception for output", "AndACustomTag", exception )

Log.logLevel = LogLevel.WARN
Log.info("This message will not be shown")

Formatting Output in Kotlin

To define an output format for StaticLog in Kotlin is very easy. It uses a mix from builders and function call syntax.
This defines for example the default format:

Log.newFormat {
    line(date("yyyy-MM-dd HH:mm:ss"), space, level, text("/"), tag, space(2), message, space(2), occurrence)
}

You can even define multiple lines and indent them:

Log.newFormat {
    line(date("yyyy-MM-dd HH:mm:ss"), space, level, text("/"), tag, space(2), occurrence)
    indent {
        line(message)
    }
}

Tag Filtering in Kotlin

It is possible to filter the output for a specific tag. This is rather easy, just provide the tag:

Log.filterTag = "filterTag"
Log.info("This log will be filtered out", "otherTag")
Log.info("This log has the right tag", "filterTag")

Deleting a tag filter is just as easy:

Log.deleteTagFilter()

Log instances in Kotlin

If you need another log instance you can create one very easy. It can have an own format and log level:

val logger = Log.kotlinInstance()
logger.debug("This message is from an individual logger instance")

The interface of individual log instances is exactly the same as the interface for the static Log class.

FormatBuilders in Kotlin

Here are all possible FormatBuilders:

FormatBuilder Output
date(Pattern) Prints the date in the given pattern (The pattern is defined in SimpleDateFormat)
epoch Prints the current time in milliseconds
level Prints the log level
tag Prints the log tag (If none was provided to the logging function, it defaults to the class name the message was logged from.)
message Prints the log message
occurrence Prints the origin of the logging (In Eclipse and IntelliJ clickable!)
space Prints 1 space
space(X: Integer) Prints X spaces
tab Prints 1 tab
tab(X: Integer) Prints X tabs
text(S: String) Prints the String S

Custom Printers in Kotlin

tbd

StaticLog in Java

You can find the example source code here.

Logging in Java

Logging with StaticLog in Kotlin is as easy as it gets:

Log.info("This is an info message");
Log.debug("This is a debug message");
Log.warn("This is a warning message","WithACustomTag");
Log.error("This is an error message with an additional Exception for output", "AndACustomTag", exception );

Log.setLogLevel(LogLevel.WARN);
Log.info("This message will not be shown");

Formatting Output in Java

To define an output format for StaticLog in Java is very easy.
This defines for example the default format:

import static de.jupf.staticlog.Log.FormatOperations.*;

...

LogFormat format = Log.newFormat();
format.line(date("yyyy-MM-dd HH:mm:ss"), space(1), level(), text("/"), tag(), space(2), message(), space(2), occurrence());

You can even define multiple lines and indent them:

LogFormat format = Log.newFormat();
format.line(date("yyyy-MM-dd HH:mm:ss"), space(1), level(), text("/"), tag(), space(2), occurrence());
format.indent(line(message()));

Tag Filtering in Java

It is possible to filter the output for a specific tag. This is rather easy, just provide the tag:

Log.setTagFilter("filterTag");
Log.info("This log will be filtered out", "otherTag");
Log.info("This log has the right tag", "filterTag");

Deleting a tag filter is just as easy:

Log.deleteTagFilter();

Log instances in Java

If you need another log instance you can create one very easy. It can have an own log level and format:

Logger logger = Log.javaInstance();
logger.debug("This message is from an individual logger instance");

The interface of individual log instances is exactly the same as the interface for the static Log class.

FormatBuilders in Java

Here are all possible FormatBuilders:

FormatBuilder Output
date(Pattern) Prints the date in the given pattern (The pattern is defined in SimpleDateFormat)
epoch() Prints the current time in milliseconds
level() Prints the log level
tag() Prints the log tag (If none was provided to the logging function, it defaults to the class name the message was logged from.)
message() Prints the log message
occurrence() Prints the origin of the logging (In Eclipse and IntelliJ clickable!)
space(X: Integer) Prints X spaces
tab(X: Integer) Prints X tabs
text(S: String) Prints the String S

Custom Printers in Java

tbd

StaticLog in Android

StaticLog automatically detects Android VMs and switches its output to the Android logger.
The default format for Android is defined like this:

format.line(message(), space(2), occurrence());

The tag is forwarded to the Android logger. If none is provided, it defaults to the class name the log was printed from.
For further questions look at StaticLog in Java

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory