Merge pull request #158 from ferd/support-unicode-strings
Support Unicode string formatting
This commit is contained in:
commit
ad559ae1f5
3 changed files with 10 additions and 10 deletions
|
@ -126,7 +126,7 @@ debug(LogState, Fun)
|
||||||
colorize(LogState, ?CYAN, false, Fun())
|
colorize(LogState, ?CYAN, false, Fun())
|
||||||
end);
|
end);
|
||||||
debug(LogState, String) ->
|
debug(LogState, String) ->
|
||||||
debug(LogState, "~s~n", [String]).
|
debug(LogState, "~ts~n", [String]).
|
||||||
|
|
||||||
%% @doc log at the debug level given the current log state with a format string
|
%% @doc log at the debug level given the current log state with a format string
|
||||||
%% and argements @see io:format/2
|
%% and argements @see io:format/2
|
||||||
|
@ -143,7 +143,7 @@ info(LogState, Fun)
|
||||||
colorize(LogState, ?GREEN, false, Fun())
|
colorize(LogState, ?GREEN, false, Fun())
|
||||||
end);
|
end);
|
||||||
info(LogState, String) ->
|
info(LogState, String) ->
|
||||||
info(LogState, "~s~n", [String]).
|
info(LogState, "~ts~n", [String]).
|
||||||
|
|
||||||
%% @doc log at the info level given the current log state with a format string
|
%% @doc log at the info level given the current log state with a format string
|
||||||
%% and argements @see io:format/2
|
%% and argements @see io:format/2
|
||||||
|
@ -160,7 +160,7 @@ error(LogState, Fun)
|
||||||
colorize(LogState, ?RED, false, Fun())
|
colorize(LogState, ?RED, false, Fun())
|
||||||
end);
|
end);
|
||||||
error(LogState, String) ->
|
error(LogState, String) ->
|
||||||
error(LogState, "~s~n", [String]).
|
error(LogState, "~ts~n", [String]).
|
||||||
|
|
||||||
%% @doc log at the error level given the current log state with a format string
|
%% @doc log at the error level given the current log state with a format string
|
||||||
%% and argements @see io:format/2
|
%% and argements @see io:format/2
|
||||||
|
@ -175,7 +175,7 @@ warn(LogState, Fun)
|
||||||
when erlang:is_function(Fun) ->
|
when erlang:is_function(Fun) ->
|
||||||
log(LogState, ?EC_WARN, fun() -> colorize(LogState, ?MAGENTA, false, Fun()) end);
|
log(LogState, ?EC_WARN, fun() -> colorize(LogState, ?MAGENTA, false, Fun()) end);
|
||||||
warn(LogState, String) ->
|
warn(LogState, String) ->
|
||||||
warn(LogState, "~s~n", [String]).
|
warn(LogState, "~ts~n", [String]).
|
||||||
|
|
||||||
%% @doc log at the warn level given the current log state with a format string
|
%% @doc log at the warn level given the current log state with a format string
|
||||||
%% and argements @see io:format/2
|
%% and argements @see io:format/2
|
||||||
|
@ -187,7 +187,7 @@ warn(LogState, FormatString, Args) ->
|
||||||
-spec log(t(), int_log_level(), log_fun()) -> ok.
|
-spec log(t(), int_log_level(), log_fun()) -> ok.
|
||||||
log(#state_t{log_level=DetailLogLevel}, LogLevel, Fun)
|
log(#state_t{log_level=DetailLogLevel}, LogLevel, Fun)
|
||||||
when DetailLogLevel >= LogLevel ->
|
when DetailLogLevel >= LogLevel ->
|
||||||
io:format("~s~n", [Fun()]);
|
io:format("~ts~n", [Fun()]);
|
||||||
log(_, _, _) ->
|
log(_, _, _) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
@ -254,10 +254,10 @@ colorize(State, Color, true, Msg) when ?VALID_COLOR(Color) ->
|
||||||
colorize(State, Color - 32, false, Msg);
|
colorize(State, Color - 32, false, Msg);
|
||||||
colorize(#state_t{caller=command_line, intensity = high},
|
colorize(#state_t{caller=command_line, intensity = high},
|
||||||
Color, false, Msg) when ?VALID_COLOR(Color) ->
|
Color, false, Msg) when ?VALID_COLOR(Color) ->
|
||||||
lists:flatten(cf:format("~!" ++ [Color] ++"~s~s", [?PREFIX, Msg]));
|
lists:flatten(cf:format("~!" ++ [Color] ++"~ts~ts", [?PREFIX, Msg]));
|
||||||
colorize(#state_t{caller=command_line, intensity = low},
|
colorize(#state_t{caller=command_line, intensity = low},
|
||||||
Color, false, Msg) when ?VALID_COLOR(Color) ->
|
Color, false, Msg) when ?VALID_COLOR(Color) ->
|
||||||
lists:flatten(cf:format("~!" ++ [Color] ++"~s~!!~s", [?PREFIX, Msg]));
|
lists:flatten(cf:format("~!" ++ [Color] ++"~ts~!!~ts", [?PREFIX, Msg]));
|
||||||
colorize(_LogState, _Color, _Bold, Msg) ->
|
colorize(_LogState, _Color, _Bold, Msg) ->
|
||||||
Msg.
|
Msg.
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ beam_to_erl_source(BeamFName, ErlFName) ->
|
||||||
Src =
|
Src =
|
||||||
erl_prettypr:format(erl_syntax:form_list(tl(Forms))),
|
erl_prettypr:format(erl_syntax:form_list(tl(Forms))),
|
||||||
{ok, Fd} = file:open(ErlFName, [write]),
|
{ok, Fd} = file:open(ErlFName, [write]),
|
||||||
io:fwrite(Fd, "~s~n", [Src]),
|
io:fwrite(Fd, "~ts~n", [Src]),
|
||||||
file:close(Fd);
|
file:close(Fd);
|
||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
|
|
|
@ -75,7 +75,7 @@ build_vsn_string(Vsn, RawRef, RawCount) ->
|
||||||
|
|
||||||
get_patch_count(RawRef) ->
|
get_patch_count(RawRef) ->
|
||||||
Ref = re:replace(RawRef, "\\s", "", [global]),
|
Ref = re:replace(RawRef, "\\s", "", [global]),
|
||||||
Cmd = io_lib:format("git rev-list --count ~s..HEAD",
|
Cmd = io_lib:format("git rev-list --count ~ts..HEAD",
|
||||||
[Ref]),
|
[Ref]),
|
||||||
case os:cmd(Cmd) of
|
case os:cmd(Cmd) of
|
||||||
"fatal: " ++ _ ->
|
"fatal: " ++ _ ->
|
||||||
|
@ -88,7 +88,7 @@ get_patch_count(RawRef) ->
|
||||||
parse_tags({}) ->
|
parse_tags({}) ->
|
||||||
parse_tags("");
|
parse_tags("");
|
||||||
parse_tags(Pattern) ->
|
parse_tags(Pattern) ->
|
||||||
Cmd = io_lib:format("git describe --abbrev=0 --tags --match \"~s*\"", [Pattern]),
|
Cmd = io_lib:format("git describe --abbrev=0 --tags --match \"~ts*\"", [Pattern]),
|
||||||
Tag = os:cmd(Cmd),
|
Tag = os:cmd(Cmd),
|
||||||
case Tag of
|
case Tag of
|
||||||
"fatal: " ++ _ ->
|
"fatal: " ++ _ ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue