63 lines
1.1 KiB
Plaintext
63 lines
1.1 KiB
Plaintext
unit BsoneDebug;
|
|
|
|
interface
|
|
uses
|
|
System.SysUtils, System.DateUtils, Winapi.Windows,
|
|
madCodeHook,
|
|
madStrings,
|
|
madTypes,
|
|
GlobalDefine;
|
|
|
|
procedure LOG(const AFormat: string; const AArgs: array of const);
|
|
|
|
implementation
|
|
|
|
var
|
|
gdebug_: Boolean = true;
|
|
|
|
|
|
procedure LOG(const AFormat: string; const AArgs: array of const);
|
|
var
|
|
Header: string;
|
|
TimeStamp: string;
|
|
LogMessage: string;
|
|
FinalLog: string;
|
|
FinalLogAnsi: AnsiString;
|
|
begin
|
|
|
|
if not gdebug_ then
|
|
Exit;
|
|
|
|
Header:= '[BSONE]';
|
|
|
|
TimeStamp := Format('[%08d:%08d] %s ',
|
|
[GetCurrentProcessId(),
|
|
GetCurrentThreadId(),
|
|
FormatDateTime('mm-dd hh:nn:ss', Now)]
|
|
);
|
|
|
|
try
|
|
LogMessage := Format(AFormat, AArgs);
|
|
except
|
|
on E: Exception do
|
|
LogMessage := '*** LOG FORMATTING ERROR: ' + E.Message + ' ***';
|
|
end;
|
|
|
|
|
|
FinalLog := Header + TimeStamp + LogMessage;
|
|
|
|
OutputDebugStringW(PChar(FinalLog));
|
|
|
|
FinalLogAnsi := AnsiString(FinalLog);
|
|
|
|
{$IFNDEF _BS1HP_}
|
|
if Length(FinalLogAnsi) > 0 then
|
|
begin
|
|
SendIpcMessage(PAnsiChar(IPC_MESSAGE_STRING), PAnsiChar(FinalLogAnsi), Length(FinalLogAnsi));
|
|
end;
|
|
{$ENDIF}
|
|
end;
|
|
|
|
|
|
end.
|