Ver código fonte

Add t to string formatting to accept unicode file and dir names

pull/510/head
Luke Bakken 5 anos atrás
pai
commit
f47a8be9a6
Nenhuma chave conhecida encontrada para esta assinatura no banco de dados ID da chave GPG: D99DE30E43EAE440
3 arquivos alterados com 10 adições e 10 exclusões
  1. +1
    -1
      src/lager.erl
  2. +3
    -3
      src/lager_crash_log.erl
  3. +6
    -6
      src/lager_file_backend.erl

+ 1
- 1
src/lager.erl Ver arquivo

@ -392,7 +392,7 @@ status() ->
Level = get_loglevel(Sink, Handler),
case Handler of
{lager_file_backend, File} ->
io_lib:format("File ~s (~s) at level ~p\n", [File, Sink, Level]);
io_lib:format("File ~ts (~s) at level ~p\n", [File, Sink, Level]);
lager_console_backend ->
io_lib:format("Console (~s) at level ~p\n", [Sink, Level]);
_ ->

+ 3
- 3
src/lager_crash_log.erl Ver arquivo

@ -80,7 +80,7 @@ init([RelFilename, MaxBytes, Size, Date, Count, Rotator]) ->
fmtmaxbytes=MaxBytes, size=Size, count=Count, date=Date,
rotator=Rotator}};
{error, Reason} ->
?INT_LOG(error, "Failed to open crash log file ~s with error: ~s",
?INT_LOG(error, "Failed to open crash log file ~ts with error: ~s",
[Filename, file:format_error(Reason)]),
{ok, #state{name=Filename, fmtmaxbytes=MaxBytes, flap=true,
size=Size, count=Count, date=Date, rotator=Rotator}}
@ -216,7 +216,7 @@ do_log({log, Event}, #state{name=Name, fd=FD, inode=Inode, flap=Flap,
Msg = io_lib:format("~s~s~s", [Time, MsgStr, NodeSuffix]),
case file:write(NewFD, unicode:characters_to_binary(Msg)) of
{error, Reason} when Flap == false ->
?INT_LOG(error, "Failed to write log message to file ~s: ~s",
?INT_LOG(error, "Failed to write log message to file ~ts: ~s",
[Name, file:format_error(Reason)]),
{ok, State#state{fd=NewFD, inode=NewInode, flap=true}};
ok ->
@ -229,7 +229,7 @@ do_log({log, Event}, #state{name=Name, fd=FD, inode=Inode, flap=Flap,
true ->
{ok, State};
_ ->
?INT_LOG(error, "Failed to reopen crash log ~s with error: ~s",
?INT_LOG(error, "Failed to reopen crash log ~ts with error: ~s",
[Name, file:format_error(Reason)]),
{ok, State#state{flap=true}}
end

+ 6
- 6
src/lager_file_backend.erl Ver arquivo

@ -126,7 +126,7 @@ init(LogFileConfig) when is_list(LogFileConfig) ->
{ok, {FD, Inode, _}} ->
State0#state{fd=FD, inode=Inode};
{error, Reason} ->
?INT_LOG(error, "Failed to open log file ~s with error ~s", [Name, file:format_error(Reason)]),
?INT_LOG(error, "Failed to open log file ~ts with error ~s", [Name, file:format_error(Reason)]),
State0#state{flap=true}
end,
{ok, State}
@ -149,7 +149,7 @@ handle_call({set_loghwm, Hwm}, #state{shaper=Shaper, name=Name} = State) ->
{ok, {error, bad_log_hwm}, State};
_ ->
NewShaper = Shaper#lager_shaper{hwm=Hwm},
?INT_LOG(notice, "Changed loghwm of ~s to ~p", [Name, Hwm]),
?INT_LOG(notice, "Changed loghwm of ~ts to ~p", [Name, Hwm]),
{ok, {last_loghwm, Shaper#lager_shaper.hwm}, State#state{shaper=NewShaper}}
end;
handle_call(rotate, State = #state{name=File}) ->
@ -255,7 +255,7 @@ write(#state{name=Name, fd=FD, inode=Inode, flap=Flap, size=RotSize,
true ->
State;
_ ->
?INT_LOG(error, "Failed to rotate log file ~s with error ~s", [Name, file:format_error(Reason)]),
?INT_LOG(error, "Failed to rotate log file ~ts with error ~s", [Name, file:format_error(Reason)]),
State#state{flap=true}
end
end;
@ -267,7 +267,7 @@ write(#state{name=Name, fd=FD, inode=Inode, flap=Flap, size=RotSize,
true ->
State;
_ ->
?INT_LOG(error, "Failed to reopen log file ~s with error ~s", [Name, file:format_error(Reason)]),
?INT_LOG(error, "Failed to reopen log file ~ts with error ~s", [Name, file:format_error(Reason)]),
State#state{flap=true}
end
end;
@ -284,7 +284,7 @@ do_write(#state{fd=FD, name=Name, flap=Flap} = State, Level, Msg) ->
%% force a sync on any message that matches the 'sync_on' bitmask
Flap2 = case file:datasync(FD) of
{error, Reason2} when Flap == false ->
?INT_LOG(error, "Failed to write log message to file ~s: ~s",
?INT_LOG(error, "Failed to write log message to file ~ts: ~s",
[Name, file:format_error(Reason2)]),
true;
ok ->
@ -327,7 +327,7 @@ validate_logfile_proplist(List) ->
end
catch
{bad_config, Msg, Value} ->
?INT_LOG(error, "~s ~p for file ~p",
?INT_LOG(error, "~s ~p for file ~tp",
[Msg, Value, proplists:get_value(file, List)]),
false
end.

Carregando…
Cancelar
Salvar