diff --git a/.github/workflows/hello-apps.yml b/.github/workflows/hello-apps.yml index 33131c347..981e0ffe2 100644 --- a/.github/workflows/hello-apps.yml +++ b/.github/workflows/hello-apps.yml @@ -15,7 +15,7 @@ jobs: smoketest: strategy: matrix: - logging: [ "OFF", "ON" ] + logging: [ "0", "1" ] fail-fast: false runs-on: "windows-2022" steps: @@ -35,4 +35,4 @@ jobs: env: BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }} OPENSSL_ROOT_DIR: ${{ steps.install-openssl.outputs.OPENSSL_ROOT_DIR }} - LD_DEBUG_LOGGING: ${{ matrix.logging }} + CFLAGS: "-D_LD_DEBUG_LOGGING=${{ matrix.logging }}" diff --git a/examples/hello-c-client/main.c b/examples/hello-c-client/main.c index ba29d4dca..a4780b8b1 100644 --- a/examples/hello-c-client/main.c +++ b/examples/hello-c-client/main.c @@ -20,12 +20,15 @@ char const* get_with_env_fallback(char const* source_val, char const* env_variable, - char const* error_msg); + char const* error); -#define print(...) \ - if (strcmp(logging, "ON") == 0) { \ - printf(__VA_ARGS__); \ - } +#if LD_DEBUG_LOGGING +#define print(...) printf(__VA_ARGS__) +#else +#define print(...) \ + do { \ + } while (0) +#endif int main() { char const* mobile_key = get_with_env_fallback( @@ -35,10 +38,9 @@ int main() { "variable.\n" "The value of MOBILE_KEY in main.c takes priority over LD_MOBILE_KEY."); - char const* logging = get_with_env_fallback( - "", "LD_DEBUG_LOGGING", "set LD_DEBUG_LOGGING to ON or OFF"); - - printf("Logging is: %s\n", logging); +#if LD_DEBUG_LOGGING + printf("Debug logging enabled\n"); +#endif print("using mobile key: %s\n", mobile_key); LDClientConfigBuilder config_builder =