HackWebRTC / kmp-xlog

KMP wrapper for tencent mars xlog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

kmp-xlog

KMP wrapper for tencent mars xlog. Maven Central

Dependency

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'

Usage

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)
}

Example

Android

Open the project (the repo root dir) in Android studio, and run the example.androidApp target.

iOS

cd example/iosApp
pod install
# open iosApp.xcworkspace in Xcode, and run it.

JS

./gradlew :example:shared:jsBrowserRun

Linux

./gradlew runKmp_xlogDebugExecutableLinuxX64

Windows

.\gradlew runKmp_xlogDebugExecutableMingwX64

macOS

./build_apple.sh
./gradlew runKmp_xlogDebugExecutableMacosX64

Test

Test shared code on Android unit test:

./gradlew :kmp-xlog:testDebugUnitTest

Then check reports in kmp-xlog/build/reports/tests/testDebugUnitTest.

Publish

iOS/macOS cocoapods

./build_apple.sh
./publish_apple_cocoapods.sh

About

KMP wrapper for tencent mars xlog

License:MIT License


Languages

Language:C++ 77.0%Language:Java 7.0%Language:C 4.7%Language:Kotlin 4.6%Language:Python 2.1%Language:Shell 1.9%Language:Objective-C 1.1%Language:Objective-C++ 0.5%Language:CMake 0.5%Language:Batchfile 0.3%Language:Swift 0.1%Language:Ruby 0.1%Language:HTML 0.0%