事务设置函数

事务设置函数

  • int lr_set_transaction_status(int status)

  设置当前所有处于执行状态的事务的结束状态。如果事务结束函数指定相关事务的结束状态为LR_AUTO,则事务按照新设置的状态结束,否则将按照原来指定的状态结束

if(event == GENERAL_ERROR)
        lr_set_transaction_status(LR_FAIL);
    lr_end_transaction("登陆",LR_AUTO);
  • int lr_set_transaction_status_by_name(int status,const char * transaction_name)

  用于指定事务的状态。如果事务结束函数指定相关事务的结束状态为LR_AUTO,则事务按照新设置的状态结束,否则将按照原来指定的状态结束

if(event == GENERAL_ERROR)
        lr_set_transaction_status_by_name(LR_FAIL,"登录");
    lr_end_transaction("登陆",LR_AUTO);
  • int lr_fail_trans_with_error(constchar * format,exp1,exp2,... expn。)

  与lr_set_transaction_instance_status 类似,都可以用于设置事务的状态,区别在于lr_fail_trans_with_error除了可以设置的状态,还可以输出错误日志信息。用法可以参考c语言的printf函数 

  Format:描述用于写入可选剩余表达式exp1,exp2,...expn的格式的字符串。您可以在引号中指定文字字符串,或者使用可用于printf的标准消息格式化。 

  exp1,exp2,.. expn:格式化和打印的可选表达式(变量)。

if(status != SUCCESS)
        lr_fail_trans_with_error("an error has occurred:%s",my_get_error_string(status));
    lr_end_transaction("登陆成功",LR_AUTO); 
    
或者
    lr_start_transaction("login");
    lr_fail_trans_with_error("%s","失败");
    lr_end_transaction("login", LR_PASS);//这里指定状态,lr_fail_trans_with_error失去作用
原文地址:https://www.cnblogs.com/lvchengda/p/12624947.html