diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index d40cfe464c..170dd7dea8 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -292,6 +292,13 @@ By [@SimonSapin](https://github.com/SimonSapin) ## 🚀 Features +### rhai logging functions now accept Dynamic parameters ([PR #1521](https://github.com/apollographql/router/pull/1521)) + +Prior to this change, rhai logging functions worked with string parameters. This change means that any valid rhai object +may now be passed as a logging parameter. + +By [@garypen](https://github.com/garypen) + ### Reduce initial memory footprint by lazily populating introspection query cache ([#1516](https://github.com/apollographql/router/issues/1516)) In an early alpha release of the Router, we only executed certain "known" introspection queries because of prior technical constraints that prohibited us from doing something more flexible. Because the set of introspection queries was "known", it made sense to cache them. @@ -304,7 +311,6 @@ This change removes the cache entirely and allows introspection queries served b By [@o0Ignition0o](https://github.com/o0Ignition0o) - ### Expose query plan in extensions for GraphQL response (experimental) ([PR #1470](https://github.com/apollographql/router/pull/1470)) Expose query plan in extensions for GraphQL response. Only experimental for now, no documentation available. diff --git a/apollo-router/src/plugins/rhai.rs b/apollo-router/src/plugins/rhai.rs index 669a6b6d20..76ff3188af 100644 --- a/apollo-router/src/plugins/rhai.rs +++ b/apollo-router/src/plugins/rhai.rs @@ -1251,20 +1251,20 @@ impl Rhai { Ok(()) }) // Register a series of logging functions - .register_fn("log_trace", |x: &str| { - tracing::trace!("{}", x); + .register_fn("log_trace", |out: Dynamic| { + tracing::trace!(%out, "rhai_trace"); }) - .register_fn("log_debug", |x: &str| { - tracing::debug!("{}", x); + .register_fn("log_debug", |out: Dynamic| { + tracing::debug!(%out, "rhai_debug"); }) - .register_fn("log_info", |x: &str| { - tracing::info!("{}", x); + .register_fn("log_info", |out: Dynamic| { + tracing::info!(%out, "rhai_info"); }) - .register_fn("log_warn", |x: &str| { - tracing::warn!("{}", x); + .register_fn("log_warn", |out: Dynamic| { + tracing::warn!(%out, "rhai_warn"); }) - .register_fn("log_error", |x: &str| { - tracing::error!("{}", x); + .register_fn("log_error", |out: Dynamic| { + tracing::error!(%out, "rhai_error"); }) // Register a function for printing to stderr .register_fn("eprint", |x: &str| { @@ -1445,15 +1445,9 @@ mod tests { let mut mock_service = MockExecutionService::new(); mock_service.expect_clone().return_once(move || { let mut mock_service = MockExecutionService::new(); - mock_service - .expect_call() - .times(1) - .returning(move |req: ExecutionRequest| { - Ok(ExecutionResponse::fake_builder() - .context(req.context) - .build()) - }); - + // The execution_service in test.rhai throws an exception, so we never + // get a call into the mock service... + mock_service.expect_call().never(); mock_service });