Debug Mode
Log Levels
enum class B2MetricAnalyticsLogLevel {
OFF, // No logs — recommended for production
ERROR, // Only critical errors
WARNING, // Errors and warnings
INFO, // General information about SDK operations
DEBUG // Detailed information for debugging
}
| Level | Shows |
|---|---|
OFF | Nothing — all logs suppressed |
ERROR | Critical failures that prevent SDK from working |
WARNING | Issues that might cause problems (e.g., invalid properties) |
INFO | SDK initialization, events sent, batch operations |
DEBUG | Detailed flow, every event logged, configuration details |
Enable Debug Logging
B2MetricAnalyticsConfig(
apiKey = "YOUR_API_KEY",
b2MetricAnalyticsLogLevel = B2MetricAnalyticsLogLevel.DEBUG
)
Development vs Production Setup
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
val logLevel = if (BuildConfig.DEBUG) {
B2MetricAnalyticsLogLevel.DEBUG
} else {
B2MetricAnalyticsLogLevel.ERROR
}
B2MetricSDK.getInstance(this).start(
B2MetricAnalyticsConfig(
apiKey = if (BuildConfig.DEBUG) "DEV_API_KEY" else "PROD_API_KEY",
batchSize = if (BuildConfig.DEBUG) 1 else 50,
b2MetricAnalyticsLogLevel = logLevel
)
)
}
}
View Logs in Logcat
Filter B2Metric logs in Android Studio's Logcat:
# Show all B2Metric logs
adb logcat | grep B2Metric
# Show only errors
adb logcat *:E | grep B2Metric