
Remote logging SDK enables logging across various platforms, supports different log levels, ensures secure project configuration, and requires internet permission for seamless operation.
A remote logging SDK for Native Android and Kotlin Multi Platform (Android, iOS, iPadOS, macOS, watchOS, tvOS).
dependencies {
implementation("io.metashark:purlog:0.9.0")
} <uses-permission android:name="android.permission.INTERNET" />class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Setup PurLog
val config = PurLogConfig.Builder()
.setEnv(PurLogEnv.DEV)
.setLevel(PurLogLevel.VERBOSE)
.setProject(
projectId = Secrets.projectId,
projectJWT = Secrets.projectJWT // pass this in securely from your server. Do not hardcode it in your app
)
.setContext(applicationContext)
.build()
// Test Logs
CoroutineScope(Dispatchers.Default).launch {
PurLog.initialize(config)
PurLog.verbose("Test Verbose", metadata = mapOf("key1" to "value1"))
PurLog.debug("Test DEBUG Log")
PurLog.info("Test INFO Log")
PurLog.warn("Test WARN Log")
PurLog.error("Test ERROR Log")
PurLog.fatal("Test FATAL Log")
}
// boilerplate UI
enableEdgeToEdge()
setContent {
PurLogNativeAndroidSampleAppTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
Text(
text = "Hello World!",
modifier = Modifier.padding(innerPadding)
)
}
}
}
}
}commonMain.dependencies {
implementation("io.metashark:purlog:0.9.0")
} <uses-permission android:name="android.permission.INTERNET" />@Composable
@Preview
fun App() {
val context = getContext()
MaterialTheme {
val config = PurLogConfig.Builder()
.setEnv(PurLogEnv.DEV)
.setLevel(PurLogLevel.VERBOSE)
.setProject(
projectId = Secrets.projectId,
projectJWT = Secrets.projectJWT // pass this in securely from your server. Do not hardcode it in your app
)
.setContext(context)
.build()
CoroutineScope(Dispatchers.Default).launch {
PurLog.initialize(config)
PurLog.verbose("Test Verbose", metadata = mapOf("key1" to "value1"))
PurLog.debug("Test DEBUG Log")
PurLog.info("Test INFO Log")
PurLog.warn("Test WARN Log")
PurLog.error("Test ERROR Log")
PurLog.fatal("Test FATAL Log")
}
}
}Note: Android environments require passing in a Context. setContext(context) can be ommited if only iOS is targeted
@Composable
expect fun getContext(): Any?import androidx.compose.ui.platform.LocalContext
@Composable
actual fun getContext(): Any? = LocalContext.current@Composable
actual fun getContext(): Any? = nullA remote logging SDK for Native Android and Kotlin Multi Platform (Android, iOS, iPadOS, macOS, watchOS, tvOS).
dependencies {
implementation("io.metashark:purlog:0.9.0")
} <uses-permission android:name="android.permission.INTERNET" />class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Setup PurLog
val config = PurLogConfig.Builder()
.setEnv(PurLogEnv.DEV)
.setLevel(PurLogLevel.VERBOSE)
.setProject(
projectId = Secrets.projectId,
projectJWT = Secrets.projectJWT // pass this in securely from your server. Do not hardcode it in your app
)
.setContext(applicationContext)
.build()
// Test Logs
CoroutineScope(Dispatchers.Default).launch {
PurLog.initialize(config)
PurLog.verbose("Test Verbose", metadata = mapOf("key1" to "value1"))
PurLog.debug("Test DEBUG Log")
PurLog.info("Test INFO Log")
PurLog.warn("Test WARN Log")
PurLog.error("Test ERROR Log")
PurLog.fatal("Test FATAL Log")
}
// boilerplate UI
enableEdgeToEdge()
setContent {
PurLogNativeAndroidSampleAppTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
Text(
text = "Hello World!",
modifier = Modifier.padding(innerPadding)
)
}
}
}
}
}commonMain.dependencies {
implementation("io.metashark:purlog:0.9.0")
} <uses-permission android:name="android.permission.INTERNET" />@Composable
@Preview
fun App() {
val context = getContext()
MaterialTheme {
val config = PurLogConfig.Builder()
.setEnv(PurLogEnv.DEV)
.setLevel(PurLogLevel.VERBOSE)
.setProject(
projectId = Secrets.projectId,
projectJWT = Secrets.projectJWT // pass this in securely from your server. Do not hardcode it in your app
)
.setContext(context)
.build()
CoroutineScope(Dispatchers.Default).launch {
PurLog.initialize(config)
PurLog.verbose("Test Verbose", metadata = mapOf("key1" to "value1"))
PurLog.debug("Test DEBUG Log")
PurLog.info("Test INFO Log")
PurLog.warn("Test WARN Log")
PurLog.error("Test ERROR Log")
PurLog.fatal("Test FATAL Log")
}
}
}Note: Android environments require passing in a Context. setContext(context) can be ommited if only iOS is targeted
@Composable
expect fun getContext(): Any?import androidx.compose.ui.platform.LocalContext
@Composable
actual fun getContext(): Any? = LocalContext.current@Composable
actual fun getContext(): Any? = null