Closed nbuyer closed 2 years ago
// 1. BTW, can not do this: GlobalLogFileProvider.FormatSettings.ShortDateFormat := 'yyyy-mm-dd hh:nn:ss'; Do you mean date format output in your file not corresponds to your selected format?
// 2. Setting GlobalLogFileProvider.FileName after enabled causes AV error later Filename should be setted before enable file provider, but i will revise to adapt to this change.
// 1. BTW, can not do this: GlobalLogFileProvider.FormatSettings.ShortDateFormat := 'yyyy-mm-dd hh:nn:ss'; Do you mean date format output in your file not corresponds to your selected format?
No, just a compiler error: [dcc32 Error] E2064 Left side cannot be assigned to
ok, FormatSettings is a record. In delphi property of record type is readonly. This is because you can read (return the entire record) or write (assign the entire record). If you want to change FormatSettings you need to assign a record to the property:
var
fsettings : TFormatSettings;
begin
fsettings.ShortDateFormat := 'yyyy-mm-dd hh:nn:ss';
GlobalLogFileProvider.FormatSettings := fsettings;
end;
// 2. Setting GlobalLogFileProvider.FileName after enabled causes AV error later
I've tried and i can change filename after enabled and new log entries was written to new file. Can you provide more info?
Thanks! New a VCL form and put a button1 on it.
procedure TForm11.Button1Click(Sender: TObject);
begin
GlobalLogFileProvider.LogLevel := LOG_ALL;
GlobalLogFileProvider.IncludedInfo := GlobalLogFileProvider.IncludedInfo + [iiThreadId];
GlobalLogFileProvider.FileName := '.\abc.log';
GlobalLogFileProvider.Enabled := True;
GlobalLogFileProvider.FileName := '.\def.log'; // Remove this line to stop AV
Logger.Providers.Add(GlobalLogFileProvider);
end;
Click the button1 and will throw this exception:
Quick.Threads.pas line 940
function TThreadedQueueList<T>.PopItem(var AQueueSize: Integer; var AItem: T): TWaitResult;
begin
AItem := Default(T);
fQueueLock.Enter; // <-- Exception break on this line
What delphi version are you using?
Please, change line 372 in Quick.Logger.Provider.Files:
if IsEnabled then Restart;
with:
if IsEnabled then Init
Please, change line 372 in Quick.Logger.Provider.Files:
if IsEnabled then Restart;
with:
if IsEnabled then Init
Problem solved! Thank you.
Hi, I tried to use this logger the very first time and encountered some minor issues. It is very easy to avoid but I just want to report what happened. Thank you.
Delphi 11.1 FMX.MultiLogger project
procedure TfrmMain.FormCreate(Sender: TObject); begin GlobalLogFileProvider.LogLevel := LOG_ALL; GlobalLogFileProvider.Enabled := True; // 1. BTW, can not do this: GlobalLogFileProvider.FormatSettings.ShortDateFormat := 'yyyy-mm-dd hh:nn:ss'; // 2. Setting GlobalLogFileProvider.FileName after enabled causes AV error later GlobalLogFileProvider.FileName := '.\abc.log'; GlobalLogFileProvider.IncludedInfo := GlobalLogFileProvider.IncludedInfo + [iiThreadId]; ...