Kotlin is an SLF4J rapping, and sometimes we want to access this directly. To use the SLF4J-logging SLF4J-API, a rapper does not need to use a wrapper Logger, class name or logger name. The Boiler Template Code does not need to write the Boiler Template code.
Generally, it would be best to use the #v, #d, #i, #w, and #e methods to write logs. We can then view the logs in log cat. The order in terms of verbosity, from least to most, is ERROR, WARN, INFO, DEBUG, VERBOSE.
Here we add the log method as an extension of the type. Another is the same as the object from Java, so we can access this method using all the events of all things and all things. We tag the class name, which removes the need to have a particular variable for this purpose.
The simplest part is that we don't take the message directly, but the message is a function. This is evaluated by the message and will never execute Lamda within the release build of the log method calls.
Another interesting part, we made the log method an inline activity. The log method is pasted on the call site and grafted body call up; the log method and method call will not appear after compromise. So it deletes the overhead of creating special activity (this is an example of a type of type function.
|