mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-25 22:39:16 +02:00
* Centralize logging for APIs
This commit is contained in:
parent
c622a245f2
commit
a2b7d84ddf
@ -254,7 +254,13 @@ type
|
|||||||
Private
|
Private
|
||||||
FEnv : TPas2JSWASIEnvironment;
|
FEnv : TPas2JSWASIEnvironment;
|
||||||
FInstanceExports: TWASIExports;
|
FInstanceExports: TWASIExports;
|
||||||
|
FLogAPI: Boolean;
|
||||||
Protected
|
Protected
|
||||||
|
property LogAPI : Boolean Read FLogAPI Write FLogAPI;
|
||||||
|
procedure DoError(const Msg: String); overload;
|
||||||
|
procedure DoError(const Fmt: String; const Args: array of const); overload;
|
||||||
|
procedure DoLog(const Msg : String); overload;
|
||||||
|
procedure DoLog(const Fmt : String; const args : Array of const); overload;
|
||||||
procedure SetInstanceExports(const AValue: TWASIExports); virtual;
|
procedure SetInstanceExports(const AValue: TWASIExports); virtual;
|
||||||
function getModuleMemoryDataView : TJSDataView;
|
function getModuleMemoryDataView : TJSDataView;
|
||||||
Public
|
Public
|
||||||
@ -756,6 +762,28 @@ begin
|
|||||||
Inherited CreateFmt(aFmt,aArgs);
|
Inherited CreateFmt(aFmt,aArgs);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TImportExtension.DoLog(const Msg: String);
|
||||||
|
begin
|
||||||
|
if LogApi then
|
||||||
|
Writeln(ClassName+': '+Msg);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TImportExtension.DoLog(const Fmt: String; const args: array of const);
|
||||||
|
begin
|
||||||
|
if LogApi then
|
||||||
|
DoLog(Format(Fmt,Args));
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TImportExtension.DoError(const Msg: String);
|
||||||
|
begin
|
||||||
|
Console.Error(ClassName+': '+Msg);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TImportExtension.DoError(const Fmt: String; const Args: array of const);
|
||||||
|
begin
|
||||||
|
Console.Error(ClassName+': '+Format(Fmt,Args));
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TImportExtension.SetInstanceExports(const AValue: TWASIExports);
|
procedure TImportExtension.SetInstanceExports(const AValue: TWASIExports);
|
||||||
begin
|
begin
|
||||||
if FInstanceExports=AValue then Exit;
|
if FInstanceExports=AValue then Exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user