Spaces:
Paused
Paused
ML Intern deploy
Deploy httpSMS gateway to Hugging Face Spaces (Docker SDK): nginx :7860 -> Go API :8000, Nuxt SPA, Android APK, bootstrap-mode entrypoint
83a59ca Download android/app/src/main/java/com/httpsms/LogzTree.kt from red-kit/httpsms-gateway: direct link, hf CLI and curl.
- Browser
- Download file 2.52 kB
-
https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/edb5ea459a6e19d91e941f078c1ff1799d310731/android/app/src/main/java/com/httpsms/LogzTree.kt
- Command line
-
hf download hf://spaces/red-kit/httpsms-gateway@edb5ea459a6e19d91e941f078c1ff1799d310731/android/app/src/main/java/com/httpsms/LogzTree.kt
-
curl -L -o LogzTree.kt https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/edb5ea459a6e19d91e941f078c1ff1799d310731/android/app/src/main/java/com/httpsms/LogzTree.kt
2.52 kB
| package com.httpsms | |
| import android.content.Context | |
| import android.os.Build | |
| import com.beust.klaxon.Json | |
| import com.beust.klaxon.Klaxon | |
| import okhttp3.MediaType.Companion.toMediaType | |
| import okhttp3.OkHttpClient | |
| import okhttp3.Request | |
| import okhttp3.RequestBody.Companion.toRequestBody | |
| import timber.log.Timber | |
| import java.time.ZoneOffset | |
| import java.time.ZonedDateTime | |
| import java.time.format.DateTimeFormatter | |
| import io.sentry.Sentry | |
| class LogzTree(val context: Context): Timber.DebugTree() { | |
| private val client = OkHttpClient() | |
| override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { | |
| val formatter: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") | |
| val logEntry = LogEntry( | |
| BuildConfig.APPLICATION_ID, | |
| BuildConfig.VERSION_NAME, | |
| priority, | |
| severity(priority), | |
| tag, | |
| message, | |
| Build.MODEL, | |
| Build.BRAND, | |
| Build.DEVICE, | |
| Build.VERSION.SDK_INT, | |
| ZonedDateTime.now(ZoneOffset.UTC).format(formatter), | |
| Settings.getUserID(context), | |
| t | |
| ) | |
| val body = Klaxon().toJsonString(listOf(logEntry)).toRequestBody("application/json".toMediaType()) | |
| val request: Request = Request.Builder() | |
| .url("https://api.axiom.co/v1/datasets/production/ingest") | |
| .post(body) | |
| .header("Content-Type", "application/json") | |
| .header("Authorization", "Bearer xaat-2a2e0b73-3702-4971-a80f-be3956934950") | |
| .build() | |
| Thread { | |
| try { | |
| val response = client.newCall(request).execute() | |
| response.body?.close() | |
| } catch(ex: Exception) { | |
| Sentry.captureException(ex) | |
| } | |
| }.start() | |
| } | |
| private fun severity(priority: Int): String { | |
| return when(priority) { | |
| 3 -> "DEBUG" | |
| 4 -> "INFO" | |
| 5 -> "WARNING" | |
| 6 -> "ERROR" | |
| 7 -> "ASSERT" | |
| else -> "VERBOSE" | |
| } | |
| } | |
| class LogEntry( | |
| val name: String, | |
| val release: String, | |
| val priority: Int, | |
| val severity: String, | |
| val tag: String?, | |
| val message: String, | |
| val model: String, | |
| val brand: String, | |
| val device: String, | |
| val version: Int, | |
| val dt: String, | |
| val userID: String, | |
| val throwable: Throwable?) | |
| } | |