KMP wrapper for tencent mars xlog.
For Android/JS/Linux/Windows, you only need to add gradle dependency, for iOS/macOS you need add an extra cocoapods dependency.
// add common source set dependency
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("com.piasy:kmp-xlog:$version")
}
}
}
}
// add iOS/macOS cocoapods dependency
pod 'kmp_xlog', '~> $version'
object Logging {
const val LEVEL_DEBUG = 1
const val LEVEL_INFO = 2
const val LEVEL_ERROR = 4
}
// Android initialize
fun initializeMarsXLog(
context: Context,
logDir: String,
level: Int,
namePrefix: String,
logToConsole: Boolean
)
// iOS/macOS/Linux/Windows initialize
fun initializeMarsXLog(
level: Int,
namePrefix: String,
logToConsole: Boolean
)
// JS initialize
fun initializeConsoleLog()
// logging
object Logging {
fun debug(tag: String, content: String)
fun info(tag: String, content: String)
fun error(tag: String, content: String)
}
Open the project (the repo root dir) in Android studio, and run the example.androidApp target.
cd example/iosApp
pod install
# open iosApp.xcworkspace in Xcode, and run it.
./gradlew :example:shared:jsBrowserRun
./gradlew runKmp_xlogDebugExecutableLinuxX64
.\gradlew runKmp_xlogDebugExecutableMingwX64
./build_apple.sh
./gradlew runKmp_xlogDebugExecutableMacosX64
Test shared code on Android unit test:
./gradlew :kmp-xlog:testDebugUnitTest
Then check reports in kmp-xlog/build/reports/tests/testDebugUnitTest
.
./build_apple.sh
./publish_apple_cocoapods.sh