服务端日志记录

procedure LogInfo(msg: string);
// 功能: 服务端日志
var
  p: PChar;
begin
  try
    GetMem(p, (Length(msg) + 1) * sizeof(char));
    Move(msg[1], p^, (Length(msg) + 1) * sizeof(char));
    PostMessage(Application.MainForm.Handle, WM_LOG, integer(p), 0);
  except
    Exit;
  end;
end;

 

procedure Tf_MainForm.Log(var msg: TMessage);
var
  p: PChar;
begin
  try
    p := PChar(msg.WParam);
    if Assigned(p) then
    begin
      AddMemo(p);
      FreeMem(p);
    end;
  except
    on E: Exception do
    begin
      LogInfo('Tf_MainForm.Log---' + E.Message);
      exit;
    end;
  end;
end;

你可能感兴趣的:(服务端)