diff --git a/src/btwxt.h b/src/btwxt.h index 1bc7432..b8346ac 100644 --- a/src/btwxt.h +++ b/src/btwxt.h @@ -123,6 +123,8 @@ class RegularGridInterpolator { void set_logger(std::shared_ptr logger); + Courierr::Courierr& get_logger() { return *btwxt_logger; }; + private: friend class TwoDFixtureWithLoggingContext; friend class TwoDFixtureWithLoggingContext_set_message_context_Test; diff --git a/test/btwxt_test.cpp b/test/btwxt_test.cpp index 8a22589..1fa5cb5 100644 --- a/test/btwxt_test.cpp +++ b/test/btwxt_test.cpp @@ -167,6 +167,14 @@ TEST_F(TwoDFixture, unique_logger_per_rgi_instance) { EXPECT_STDOUT(test_rgi.set_new_target(short_target);, expected_error); // Recheck } +TEST_F(TwoDFixture, access_logger_in_btwxt) { + RegularGridInterpolator rgi2(test_gridded_data, std::make_shared()); + std::string context_str{"RGI2 Context:"}; + rgi2.get_logger().set_message_context(reinterpret_cast(&context_str)); + std::string expected_error2{"RGI2 Context: ERROR: Target and Gridded Data do not have the same dimensions.\n"}; + EXPECT_STDOUT(rgi2.set_new_target({1});, expected_error2); +} + //TODO: Test that logger copies in GriddedData/GridPoint also receive modified context TEST_F(OneDFixture, cubic_interpolate) {