mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 00:39:44 +02:00
LazLogger: Optimize indent handling
git-svn-id: trunk@60262 -
This commit is contained in:
parent
e662e97111
commit
185d63ac35
@ -159,8 +159,8 @@ type
|
||||
procedure ClearAllBlockHandler;
|
||||
|
||||
|
||||
procedure DoDbgOut(const s: string); override;
|
||||
procedure DoDebugLn(const s: string); override;
|
||||
procedure DoDbgOut(s: string); override;
|
||||
procedure DoDebugLn(s: string); override;
|
||||
procedure DoDebuglnStack(const s: string); override;
|
||||
|
||||
property FileHandle: TLazLoggerFileHandle read GetFileHandle write SetFileHandle;
|
||||
@ -708,62 +708,60 @@ begin
|
||||
while BlockHandlerCount > 0 do RemoveBlockHandler(BlockHandler[0]);
|
||||
end;
|
||||
|
||||
procedure TLazLoggerFile.DoDbgOut(const s: string);
|
||||
procedure TLazLoggerFile.DoDbgOut(s: string);
|
||||
var
|
||||
Handled: Boolean;
|
||||
s2: String;
|
||||
begin
|
||||
if not IsInitialized then Init;
|
||||
|
||||
EnterCriticalsection(FIndentCriticalSection);
|
||||
s2 := FDebugIndent + s;
|
||||
LeaveCriticalsection(FIndentCriticalSection);
|
||||
(* DoDbgOut in not useful in threaded environment.
|
||||
Therefore FDebugNestAtBOL is not handled in a thread safe way.
|
||||
If DoDbgOut is *not* used at all, the FDebugNestAtBOL is always true, and
|
||||
dirty reads should therefore yield the correct value: "true"
|
||||
*)
|
||||
|
||||
if FDebugNestAtBOL and (s <> '') and (FDebugNestLvl <> 0) then begin
|
||||
EnterCriticalsection(FIndentCriticalSection);
|
||||
//if FDebugNestAtBOL then
|
||||
s := FDebugIndent + s;
|
||||
//FDebugNestAtBOL := (s[length(s)] in [#10,#13]);
|
||||
LeaveCriticalsection(FIndentCriticalSection);
|
||||
end;
|
||||
FDebugNestAtBOL := (s = '') or (s[length(s)] in [#10,#13]);
|
||||
|
||||
if OnDbgOut <> nil then
|
||||
begin
|
||||
Handled := False;
|
||||
if FDebugNestAtBOL and (s <> '') then
|
||||
OnDbgOut(Self, s2, Handled)
|
||||
else
|
||||
OnDbgOut(Self, s, Handled);
|
||||
OnDbgOut(Self, s, Handled);
|
||||
if Handled then
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if FDebugNestAtBOL and (s <> '') then
|
||||
FileHandle.WriteToFile(s2, Self)
|
||||
else
|
||||
FileHandle.WriteToFile(s, Self);
|
||||
FDebugNestAtBOL := (s = '') or (s[length(s)] in [#10,#13]);
|
||||
FileHandle.WriteToFile(s, Self);
|
||||
end;
|
||||
|
||||
procedure TLazLoggerFile.DoDebugLn(const s: string);
|
||||
procedure TLazLoggerFile.DoDebugLn(s: string);
|
||||
var
|
||||
Handled: Boolean;
|
||||
s2: String;
|
||||
begin
|
||||
if not IsInitialized then Init;
|
||||
|
||||
EnterCriticalsection(FIndentCriticalSection);
|
||||
s2 := FDebugIndent + s;
|
||||
LeaveCriticalsection(FIndentCriticalSection);
|
||||
if FDebugNestAtBOL and (s <> '') and (FDebugNestLvl <> 0) then begin
|
||||
EnterCriticalsection(FIndentCriticalSection);
|
||||
s := FDebugIndent + s;
|
||||
LeaveCriticalsection(FIndentCriticalSection);
|
||||
end;
|
||||
FDebugNestAtBOL := True;
|
||||
|
||||
if OnDebugLn <> nil then
|
||||
begin
|
||||
Handled := False;
|
||||
if FDebugNestAtBOL and (s <> '') then
|
||||
OnDebugLn(Self, s2, Handled)
|
||||
else
|
||||
OnDebugLn(Self, s, Handled);
|
||||
OnDebugLn(Self, s, Handled);
|
||||
if Handled then
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if FDebugNestAtBOL and (s <> '') then
|
||||
FileHandle.WriteLnToFile(LineBreaksToSystemLineBreaks(s2), Self)
|
||||
else
|
||||
FileHandle.WriteLnToFile(LineBreaksToSystemLineBreaks(s), Self);
|
||||
FDebugNestAtBOL := True;
|
||||
FileHandle.WriteLnToFile(LineBreaksToSystemLineBreaks(s), Self);
|
||||
end;
|
||||
|
||||
procedure TLazLoggerFile.DoDebuglnStack(const s: string);
|
||||
|
@ -120,8 +120,8 @@ type
|
||||
procedure IndentChanged; virtual;
|
||||
function GetBlockHandler({%H-}AIndex: Integer): TLazLoggerBlockHandler; virtual;
|
||||
|
||||
procedure DoDbgOut(const {%H-}s: string); virtual;
|
||||
procedure DoDebugLn(const {%H-}s: string); virtual;
|
||||
procedure DoDbgOut({%H-}s: string); virtual;
|
||||
procedure DoDebugLn({%H-}s: string); virtual;
|
||||
procedure DoDebuglnStack(const {%H-}s: string); virtual;
|
||||
|
||||
function ArgsToString(Args: array of const): string;
|
||||
@ -728,12 +728,12 @@ begin
|
||||
//
|
||||
end;
|
||||
|
||||
procedure TLazLogger.DoDbgOut(const s: string);
|
||||
procedure TLazLogger.DoDbgOut(s: string);
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
procedure TLazLogger.DoDebugLn(const s: string);
|
||||
procedure TLazLogger.DoDebugLn(s: string);
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user