MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / write_log

Function write_log

crates/opencode-server/src/routes.rs:4275–4296  ·  view source on GitHub ↗
(Json(req): Json<WriteLogRequest>)

Source from the content-addressed store, hash-verified

4273}
4274
4275async fn write_log(Json(req): Json<WriteLogRequest>) -> Result<Json<bool>> {
4276 let extra_str = req
4277 .extra
4278 .as_ref()
4279 .map(|e| serde_json::to_string(e).unwrap_or_default())
4280 .unwrap_or_default();
4281
4282 match req.level.as_str() {
4283 "debug" => tracing::debug!(service = %req.service, extra = %extra_str, "{}", req.message),
4284 "info" => tracing::info!(service = %req.service, extra = %extra_str, "{}", req.message),
4285 "warn" => tracing::warn!(service = %req.service, extra = %extra_str, "{}", req.message),
4286 "error" => tracing::error!(service = %req.service, extra = %extra_str, "{}", req.message),
4287 other => {
4288 return Err(ApiError::BadRequest(format!(
4289 "invalid log level: '{}', expected one of: debug, info, warn, error",
4290 other
4291 )));
4292 }
4293 }
4294
4295 Ok(Json(true))
4296}
4297
4298async fn event_stream(
4299 State(state): State<Arc<ServerState>>,

Callers

nothing calls this directly

Calls 1

as_strMethod · 0.45

Tested by

no test coverage detected