使用日志

使用日志

引用日志单元:

uses core.log;

使用方法,请看代码中的注释:

procedure TDanWei.Select(AContext: TContext);
var
  LDB: TDB;
  LPool: TDBPool;
  LRequest, LResponse: TJsonO;
begin
  LRequest := SO(AContext.InContent);
  if LRequest = nil then
    Exit;
  LResponse := TJsonO.Create;
  try
    try
      LPool := GetDBPool(LRequest.S[TConst.DBId]);
      LDB := LPool.Lock;
      LDB.Select('select * from tunit');
      LResponse.B[TConst.Success] := True;
      LResponse.S[TConst.Msg] := '查询成功';
      LResponse.A[TConst.Fields] := LDB.qry.FieldsToJsonArray;
      LResponse.A[TConst.Data] := LDB.qry.DataToJsonArray;
      AContext.Send(LResponse);
    except
      on E: Exception do
      begin
        LResponse.B[TConst.Success] := False;
        LResponse.S[TConst.Msg] := E.Message;
        AContext.Send(LResponse);
        WriteLog('TDanWei.Select()' + E.Message);//写异常日志
      end;
    end;
  finally
    LPool.Unlock(LDB);
    LResponse.Free;
    LRequest.Free;
  end;
end;

 

posted @ 2025-04-29 11:46  delphi中间件  阅读(21)  评论(0)    收藏  举报