You are not logged in.
Pages: 1
I have switched to the latest mORMot2 version. The following source code has worked so far. Two log files are now created. One for TSynLog and one for TVGServerLog.
type
TVGServerLog = class(TSynLog)
protected
procedure ComputeFileName; override;
end;
constructor TVGServerDaemon.Create;
begin
inherited Create(TVGServerSettings, ...
Settings.LogPath := TFileUtils.GetLogFileFolder(TVGServerSettings(Settings).ServerID);
Settings.SetLog(TVGServerLog);
Now TSynDaemon.AfterCreate must be overwritten. Name AfterCreate() does not really say what is being done. Perhaps a name like SetLogClassAfterCreate() would be more descriptive. If the LogClass has already been assigned in TSynDaemonSettings Create, it will be overwritten in AfterCreate(). Maybe check for Nil:
procedure TSynDaemon.AfterCreate;
begin
if RunFromSynTests then
fSettings.fLogClass := TSynLog // share the same TSynLog for all daemons
else if fSettings.LogClass = Nil then
fSettings.SetLog(TSynLog); // real world logging
end;
Best wishes and a Happy New Year 2024 to all.
With best regards
Thomas
Offline
Renaming may not be the best idea because this method is virtual, and its behavior could change when overridden.
This was one point of its introduction: you could change the default behavior, but by default logging is enabled.
So renaming may not be an option.
I have enhanced the documentation to emphasize this breaking change:
https://github.com/synopse/mORMot2/commit/50eaf926
Offline
Pages: 1