📄 debugunit.pas
字号:
unit DebugUnit;
interface
uses
SysUtils, Windows;
procedure LogDbgMsg(const msg: string; ToFile: Boolean = True);
var
LogFileName: string;
implementation
procedure LogDbgMsg(const msg: string; ToFile: Boolean = True);
const
CRLF: word = $0A0D;
var
fid: Integer;
fn, tm: string;
begin
if msg = '' then exit;
if not tofile then
begin
outputdebugstring(pchar(msg));
exit;
end;
fn := logfilename+'(Thrd_'+inttohex(getcurrentthreadid, 8)+').log';
if not fileexists(fn) then
fid := filecreate(fn)
else
fid := fileopen(fn, fmOpenWrite or fmShareDenyNone);
if fid > 0 then
begin
tm := formatdatetime('hh:nn:ss:ms', now)+#9;
fileseek(fid, 0, 2);
filewrite(fid, tm[1], length(tm));
filewrite(fid, msg[1], length(msg));
filewrite(fid, crlf, 2);
fileclose(fid);
end;
end;
initialization
forcedirectories(paramstr(0)+'.Logs\');
logfilename := paramstr(0)+'.Logs\Log@'+formatdatetime('mm-dd hh.nn', now);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -