diff --git a/src/hocon_cli.erl b/src/hocon_cli.erl index 9e77160..7d77575 100644 --- a/src/hocon_cli.erl +++ b/src/hocon_cli.erl @@ -412,10 +412,8 @@ stringify_line(K, V) when is_list(V) -> stringify_line(K, V) -> io_lib:format("~s ~w", [K, V]). -log_for_generator(_Level, #{hocon_env_var_name := Var, path := P, value := V}) when is_binary(V) -> - ?STDOUT("~s = ~s = ~s", [P, Var, V]); log_for_generator(_Level, #{hocon_env_var_name := Var, path := P, value := V}) -> - ?STDOUT("~s = ~s = ~0p", [P, Var, V]); + log_env_override(Var, P, V); log_for_generator(debug, _Args) -> ok; log_for_generator(info, _Args) -> @@ -425,6 +423,15 @@ log_for_generator(Level, Msg) when is_binary(Msg) -> log_for_generator(Level, Args) -> io:format(standard_error, "[~0p] ~0p~n", [Level, Args]). +log_env_override(Var, Path, Value) -> + ValueStr = + case Value of + V when is_binary(V) -> V; + V when is_map(V) -> "{...}"; + V -> io_lib:format("~0p", [V]) + end, + ?STDOUT("~s [~s]: ~s", [Var, Path, ValueStr]). + -ifndef(TEST). stop_deactivate() -> init:stop(1), diff --git a/test/hocon_cli_tests.erl b/test/hocon_cli_tests.erl index aebb8a8..4781087 100644 --- a/test/hocon_cli_tests.erl +++ b/test/hocon_cli_tests.erl @@ -140,6 +140,7 @@ generate_with_env_logging_test() -> ] ], [ + {"ZZZ_FOO", "{min: 1, max: 2}"}, {"ZZZ_FOO__MIN", "42"}, {"ZZZ_FOO__MAX", "43"}, {"HOCON_ENV_OVERRIDE_PREFIX", "ZZZ_"} @@ -148,8 +149,9 @@ generate_with_env_logging_test() -> {ok, Stdout} = cuttlefish_test_group_leader:get_output(), ?assertEqual( [ - <<"foo.max = ZZZ_FOO__MAX = 43">>, - <<"foo.min = ZZZ_FOO__MIN = 42">> + <<"ZZZ_FOO [foo]: {...}">>, + <<"ZZZ_FOO__MAX [foo.max]: 43">>, + <<"ZZZ_FOO__MIN [foo.min]: 42">> ], lists:sort( binary:split(