fix: add language strings for companion server; fix startup logging and null safety
This commit is contained in:
@@ -2837,6 +2837,24 @@
|
||||
"description": "Automatically deletes cached events that are older than the specified amount of time"
|
||||
}
|
||||
}
|
||||
},
|
||||
"companion_server": {
|
||||
"name": "Companion Server",
|
||||
"description": "Local web server that streams live logs and network calls to a browser dashboard",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"name": "Enabled",
|
||||
"description": "Start the companion web server inside Snapchat's process. Requires a restart."
|
||||
},
|
||||
"port": {
|
||||
"name": "Port",
|
||||
"description": "Port the server listens on (1024–65535). Default is 8484."
|
||||
},
|
||||
"token": {
|
||||
"name": "Auth Token",
|
||||
"description": "Secret token required to access the dashboard. Must not be empty. Requires a restart."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
|
||||
@@ -31,17 +31,22 @@ class CompanionServer : Feature("CompanionServer") {
|
||||
|
||||
override fun init() {
|
||||
val config = context.config.companionServer
|
||||
if (!config.enabled.get()) return
|
||||
if (!config.enabled.get()) {
|
||||
context.log.verbose("Companion Server: disabled in config", "CompanionServer")
|
||||
return
|
||||
}
|
||||
|
||||
val token = config.token.get().trim()
|
||||
if (token.isEmpty()) {
|
||||
context.log.warn("Companion Server: no token set — server disabled", "CompanionServer")
|
||||
context.log.warn("Companion Server: no auth token set — server will not start", "CompanionServer")
|
||||
return
|
||||
}
|
||||
|
||||
val port = config.port.get().coerceIn(1024, 65535)
|
||||
|
||||
hookLogOutput()
|
||||
runCatching { hookLogOutput() }.onFailure {
|
||||
context.log.warn("Companion Server: log hooking unavailable (${it.message})", "CompanionServer")
|
||||
}
|
||||
subscribeToNetworkEvents()
|
||||
startServer(port, token)
|
||||
}
|
||||
@@ -57,8 +62,8 @@ class CompanionServer : Feature("CompanionServer") {
|
||||
isCapturing.set(true)
|
||||
try {
|
||||
val priority = param.arg<Int>(0)
|
||||
val tag = param.arg<String>(1)
|
||||
val message = param.arg<String>(2)
|
||||
val tag = param.argNullable<String>(1) ?: ""
|
||||
val message = param.argNullable<String>(2) ?: ""
|
||||
val level = when (priority) {
|
||||
Log.VERBOSE -> "V"
|
||||
Log.DEBUG -> "D"
|
||||
|
||||
Reference in New Issue
Block a user