@@ -954,12 +954,12 @@ TSynLogFamily = class
954
954
read fWithInstancePointer write fWithInstancePointer;
955
955
// / the time (in seconds) after which the log content must be written on
956
956
// disk, whatever the current content size is
957
- // - by default, the log file will be written for every 8KB of log (see
958
- // BufferSize property) - this will ensure that the main application won't
959
- // be slow down by logging
960
- // - in order not to loose any log, a background thread can be created
961
- // and will be responsible of flushing all pending log content every
962
- // period of time (e.g. every 10 seconds)
957
+ // - equals 0 by default, so that the log file will be written for every 8KB
958
+ // of log (see BufferSize property) - to ensure that the main application
959
+ // won't be slow down during logging
960
+ // - in order not to loose any log, e.g. on an idle server, a background
961
+ // thread can be created and will be responsible of flushing all pending
962
+ // log content every period of time (e.g. every 10 seconds)
963
963
property AutoFlushTimeOut: cardinal
964
964
read fAutoFlushTimeOut write fAutoFlushTimeOut;
965
965
{ $ifdef OSWINDOWS}
@@ -6142,10 +6142,10 @@ procedure TSynLog.CreateLogWriter;
6142
6142
fWriterEcho.EchoAdd(fFamily.EchoCustom);
6143
6143
if Assigned(fFamily.fEchoRemoteClient) then
6144
6144
fWriterEcho.EchoAdd(fFamily.fEchoRemoteEvent);
6145
+ fWriter.OnFlushToStream := OnFlushToStream; // note: overwrites fWriterEcho
6145
6146
// enable background writing in its own TAutoFlushThread
6146
6147
if fFamily.AutoFlushTimeOut <> 0 then
6147
6148
begin
6148
- fWriter.OnFlushToStream := OnFlushToStream; // note: overwrites fWriterEcho
6149
6149
OnFlushToStream(nil , 0 );
6150
6150
fFamily.EnsureAutoFlushThreadRunning;
6151
6151
end ;
@@ -6154,6 +6154,7 @@ procedure TSynLog.CreateLogWriter;
6154
6154
procedure TSynLog.OnFlushToStream (Text: PUtf8Char; Len: PtrInt);
6155
6155
var
6156
6156
flushsec, tix32: cardinal;
6157
+ flushbytes: PtrInt;
6157
6158
begin
6158
6159
// compute the next idle timestamp for the background TAutoFlushThread
6159
6160
tix32 := 0 ;
@@ -6165,8 +6166,10 @@ procedure TSynLog.OnFlushToStream(Text: PUtf8Char; Len: PtrInt);
6165
6166
end ;
6166
6167
// check for any PerformRotation - delayed in TSynLog.LogEnterFmt
6167
6168
if not (pendingRotate in fPendingFlags) then
6168
- if (fFileRotationBytes > 0 ) and // reached size to rotate?
6169
- (fWriter.WrittenBytes + Len > fFileRotationBytes) then
6169
+ begin
6170
+ flushbytes := fFileRotationBytes;
6171
+ if (flushbytes > 0 ) and // reached size to rotate?
6172
+ (fWriter.WrittenBytes + Len > flushbytes) then
6170
6173
include(fPendingFlags, pendingRotate)
6171
6174
else
6172
6175
begin
@@ -6180,6 +6183,7 @@ procedure TSynLog.OnFlushToStream(Text: PUtf8Char; Len: PtrInt);
6180
6183
// PerformRotation will call ComputeFileName to recompute DailyTix32
6181
6184
end ;
6182
6185
end ;
6186
+ end ;
6183
6187
// chain to the fWriterEcho process (otherwise Text/Len buffer is lost)
6184
6188
fWriterEcho.FlushToStream(Text, Len);
6185
6189
end ;
0 commit comments