Skip to content

Commit

Permalink
Better DebugLn
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Aug 10, 2023
1 parent 695d1eb commit 63979e1
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 27 deletions.
4 changes: 1 addition & 3 deletions Source/Simba.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

uses
simba.init,
Classes, SysUtils, Interfaces, Forms, LazLogger,
Classes, SysUtils, Interfaces, Forms,
simba.mufasatypes, simba.main,
simba.aboutform, simba.debugimageform, simba.imagetostringform,
simba.functionlistform, simba.scripttabsform, simba.outputform,
Expand All @@ -25,8 +25,6 @@
SetHeapTraceOutput(IntToStr(GetProcessID()) + '.trc');
{$ENDIF}

DebugLogger.CloseLogFileBetweenWrites := True;

Application.CaptureExceptions := False;
Application.Initialize();

Expand Down
5 changes: 1 addition & 4 deletions Source/codetools/mpaslex.pas
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface

uses
SysUtils, Classes,
simba.list, simba.stack,
simba.mufasatypes, simba.list, simba.stack,
mPasLexTypes;

type
Expand Down Expand Up @@ -248,9 +248,6 @@ TmwPasLex = class(TmwBasePasLex)

implementation

uses
lazloggerbase;

procedure TmwBasePasLex.ClearDefines;
var
Frame: PDefineRec;
Expand Down
10 changes: 5 additions & 5 deletions Source/codetools/msimplepaspar.pas
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ interface

uses
SysUtils, Classes,
mPasLexTypes, mPasLex;
mPasLexTypes, mPasLex,
simba.mufasatypes;

const
ClassMethodDirectiveEnum = [
Expand Down Expand Up @@ -366,11 +367,10 @@ TmwSimplePasPar = class(TObject)

implementation

{$IFDEF PARSER_BENCHMARK}
uses
LazLoggerBase
{$IFDEF PARSER_BENCHMARK},
simba.datetime
{$ENDIF};
simba.datetime;
{$ENDIF}

procedure TmwSimplePasPar.ForwardDeclaration;
begin
Expand Down
6 changes: 3 additions & 3 deletions Source/script/imports/simba/simba.import_internal.pas
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ procedure ImportInternal(Compiler: TSimbaScript_Compiler);
implementation

uses
lazloggerbase, lptypes,
lptypes,
simba.tpa, simba.algo_sort, simba.algo_unique,
simba.algo_difference, simba.algo_intersection, simba.algo_symmetricDifference,
simba.script, simba.bitmap, simba.process;

procedure _LapeWrite(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
DbgOut(PString(Params^[0])^);
Debug(PString(Params^[0])^);
end;

procedure _LapeWriteLn(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV
begin
DebugLn();
DebugLn('');
end;

// Sort
Expand Down
2 changes: 1 addition & 1 deletion Source/simba.dockinghelpers.pas
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ TAnchorDockMasterHelper = class helper for TAnchorDockMaster
implementation

uses
anchordockstorage, xmlpropstorage, lazloggerbase, lazconfigstorage,
anchordockstorage, xmlpropstorage, lazconfigstorage,
simba.theme, simba.fonthelpers;

procedure TSimbaAnchorDockHeader.ParentFontChanged;
Expand Down
32 changes: 23 additions & 9 deletions Source/simba.mufasatypes.pas
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,9 @@ TComplex = record
{$POP}

var
DoSimbaDebugLn: procedure(const S: String) of object;
DoSimbaDebugLn: procedure(const S: String) of object = nil;

procedure Debug(const Msg: String);
procedure DebugLn(const Msg: String); overload;
procedure DebugLn(const Msg: String; Args: array of const); overload;

Expand Down Expand Up @@ -415,7 +416,7 @@ procedure AssertMainThread(const Method: String);
implementation

uses
math, forms, lazloggerbase, uregexpr, strutils, jsonparser, jsonscanner,
math, forms, uregexpr, strutils, jsonparser, jsonscanner,
simba.math, simba.overallocatearray, simba.geometry,
simba.algo_sort, simba.tpa, simba.random;

Expand Down Expand Up @@ -453,14 +454,27 @@ implementation

{$UNDEF BODY}

procedure Debug(const Msg: String);
begin
{$I-}
Write(Msg);
{$I+}
end;

procedure DebugLn(const Msg: String);
begin
DebugLogger.DebugLn(Msg);
{$I-}
WriteLn(Msg);
Flush(Output);
{$I+}
end;

procedure DebugLn(const Msg: String; Args: array of const);
begin
DebugLogger.DebugLn(Msg, Args);
{$I-}
WriteLn(Format(Msg, Args));
Flush(Output);
{$I+}
end;

procedure SimbaException(Message: String; Args: array of const);
Expand Down Expand Up @@ -535,12 +549,15 @@ function FlagsFromString(var Str: String): EDebugLnFlags;

procedure SimbaDebugLn(const Flags: EDebugLnFlags; const Msg: String);
begin
DoSimbaDebugLn(FlagsToString(Flags) + Msg);
if Assigned(DoSimbaDebugLn) then
DoSimbaDebugLn(FlagsToString(Flags) + Msg)
else
DebugLn(FlagsToString(Flags) + Msg);
end;

procedure SimbaDebugLn(const Flags: EDebugLnFlags; const Msg: TStringArray);
begin
DoSimbaDebugLn(FlagsToString(Flags) + LineEnding.Join(Msg));
SimbaDebugLn(Flags, LineEnding.Join(Msg));
end;

function Min(const A, B: Integer): Integer;
Expand Down Expand Up @@ -650,8 +667,5 @@ function IfThen(const Val: Boolean; const IfTrue, IfFalse: String): String;
Result := IfFalse;
end;

initialization
DoSimbaDebugLn := @DebugLogger.DebugLn;

end.

2 changes: 1 addition & 1 deletion Source/simba.nativeinterface_linux.pas
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ TSimbaNativeInterface_Linux = class(TSimbaNativeInterface)
implementation

uses
x, xatom, keysym, baseunix, unix, linux, lcltype, lazloggerbase, ctypes,
x, xatom, keysym, baseunix, unix, linux, lcltype, ctypes,
simba.process, simba.xlib, simba.windowhandle;

const
Expand Down
3 changes: 2 additions & 1 deletion Source/simba.xlib.pas
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ TSimbaXLib = record
implementation

uses
dl, lazloggerbase;
dl,
simba.mufasatypes;

function dlmopen(ID: SizeInt; Path: PChar; Flags: Integer): Pointer; cdecl; external;

Expand Down

0 comments on commit 63979e1

Please sign in to comment.