mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 02:59:21 +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 ClearAllBlockHandler;
|
||||||
|
|
||||||
|
|
||||||
procedure DoDbgOut(const s: string); override;
|
procedure DoDbgOut(s: string); override;
|
||||||
procedure DoDebugLn(const s: string); override;
|
procedure DoDebugLn(s: string); override;
|
||||||
procedure DoDebuglnStack(const s: string); override;
|
procedure DoDebuglnStack(const s: string); override;
|
||||||
|
|
||||||
property FileHandle: TLazLoggerFileHandle read GetFileHandle write SetFileHandle;
|
property FileHandle: TLazLoggerFileHandle read GetFileHandle write SetFileHandle;
|
||||||
@ -708,62 +708,60 @@ begin
|
|||||||
while BlockHandlerCount > 0 do RemoveBlockHandler(BlockHandler[0]);
|
while BlockHandlerCount > 0 do RemoveBlockHandler(BlockHandler[0]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazLoggerFile.DoDbgOut(const s: string);
|
procedure TLazLoggerFile.DoDbgOut(s: string);
|
||||||
var
|
var
|
||||||
Handled: Boolean;
|
Handled: Boolean;
|
||||||
s2: String;
|
|
||||||
begin
|
begin
|
||||||
if not IsInitialized then Init;
|
if not IsInitialized then Init;
|
||||||
|
|
||||||
EnterCriticalsection(FIndentCriticalSection);
|
(* DoDbgOut in not useful in threaded environment.
|
||||||
s2 := FDebugIndent + s;
|
Therefore FDebugNestAtBOL is not handled in a thread safe way.
|
||||||
LeaveCriticalsection(FIndentCriticalSection);
|
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
|
if OnDbgOut <> nil then
|
||||||
begin
|
begin
|
||||||
Handled := False;
|
Handled := False;
|
||||||
if FDebugNestAtBOL and (s <> '') then
|
OnDbgOut(Self, s, Handled);
|
||||||
OnDbgOut(Self, s2, Handled)
|
|
||||||
else
|
|
||||||
OnDbgOut(Self, s, Handled);
|
|
||||||
if Handled then
|
if Handled then
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if FDebugNestAtBOL and (s <> '') then
|
FileHandle.WriteToFile(s, Self);
|
||||||
FileHandle.WriteToFile(s2, Self)
|
|
||||||
else
|
|
||||||
FileHandle.WriteToFile(s, Self);
|
|
||||||
FDebugNestAtBOL := (s = '') or (s[length(s)] in [#10,#13]);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazLoggerFile.DoDebugLn(const s: string);
|
procedure TLazLoggerFile.DoDebugLn(s: string);
|
||||||
var
|
var
|
||||||
Handled: Boolean;
|
Handled: Boolean;
|
||||||
s2: String;
|
|
||||||
begin
|
begin
|
||||||
if not IsInitialized then Init;
|
if not IsInitialized then Init;
|
||||||
|
|
||||||
EnterCriticalsection(FIndentCriticalSection);
|
if FDebugNestAtBOL and (s <> '') and (FDebugNestLvl <> 0) then begin
|
||||||
s2 := FDebugIndent + s;
|
EnterCriticalsection(FIndentCriticalSection);
|
||||||
LeaveCriticalsection(FIndentCriticalSection);
|
s := FDebugIndent + s;
|
||||||
|
LeaveCriticalsection(FIndentCriticalSection);
|
||||||
|
end;
|
||||||
|
FDebugNestAtBOL := True;
|
||||||
|
|
||||||
if OnDebugLn <> nil then
|
if OnDebugLn <> nil then
|
||||||
begin
|
begin
|
||||||
Handled := False;
|
Handled := False;
|
||||||
if FDebugNestAtBOL and (s <> '') then
|
OnDebugLn(Self, s, Handled);
|
||||||
OnDebugLn(Self, s2, Handled)
|
|
||||||
else
|
|
||||||
OnDebugLn(Self, s, Handled);
|
|
||||||
if Handled then
|
if Handled then
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if FDebugNestAtBOL and (s <> '') then
|
FileHandle.WriteLnToFile(LineBreaksToSystemLineBreaks(s), Self);
|
||||||
FileHandle.WriteLnToFile(LineBreaksToSystemLineBreaks(s2), Self)
|
|
||||||
else
|
|
||||||
FileHandle.WriteLnToFile(LineBreaksToSystemLineBreaks(s), Self);
|
|
||||||
FDebugNestAtBOL := True;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazLoggerFile.DoDebuglnStack(const s: string);
|
procedure TLazLoggerFile.DoDebuglnStack(const s: string);
|
||||||
|
@ -120,8 +120,8 @@ type
|
|||||||
procedure IndentChanged; virtual;
|
procedure IndentChanged; virtual;
|
||||||
function GetBlockHandler({%H-}AIndex: Integer): TLazLoggerBlockHandler; virtual;
|
function GetBlockHandler({%H-}AIndex: Integer): TLazLoggerBlockHandler; virtual;
|
||||||
|
|
||||||
procedure DoDbgOut(const {%H-}s: string); virtual;
|
procedure DoDbgOut({%H-}s: string); virtual;
|
||||||
procedure DoDebugLn(const {%H-}s: string); virtual;
|
procedure DoDebugLn({%H-}s: string); virtual;
|
||||||
procedure DoDebuglnStack(const {%H-}s: string); virtual;
|
procedure DoDebuglnStack(const {%H-}s: string); virtual;
|
||||||
|
|
||||||
function ArgsToString(Args: array of const): string;
|
function ArgsToString(Args: array of const): string;
|
||||||
@ -728,12 +728,12 @@ begin
|
|||||||
//
|
//
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazLogger.DoDbgOut(const s: string);
|
procedure TLazLogger.DoDbgOut(s: string);
|
||||||
begin
|
begin
|
||||||
//
|
//
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazLogger.DoDebugLn(const s: string);
|
procedure TLazLogger.DoDebugLn(s: string);
|
||||||
begin
|
begin
|
||||||
//
|
//
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user