Use a single object : Logger
in your kotlin shared projects to display logs
Note you can also use it in your real code on Android & iOs
Compatible with kotlin android and kotlin native for iphone
class MyPresenter {
val TAG = "MyPresenter"
fun start(){
Logger.d(TAG, "my message")
try{
//myMethod
} catch(e: Throwable){
Logger.e(TAG, e.message, e)
}
}
}
Add the repository
repositories {
maven { url "https://dl.bintray.com/florent37/maven" }
}
implementation "com.github.florent37:multiplatform-log:1.5.0"
Uses inside the Console / print
implementation "com.github.florent37:multiplatform-log-ios:1.5.0"
Uses inside the Logcat
implementation "com.github.florent37:multiplatform-log-android:1.5.0"
Enable the logger just on debug :
Logger.enabled = BuildConfig.DEBUG
Log.d(TAG, message)
Log.e(TAG, message, throwable)
Copyright 2018 Florent37
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.