Example: switch
The following example contains a switch statement that tests the value of rc. If rc's value is 1, then the transaction is deemed a success.
int rc; lr_start_transaction ("deposit");
// Server API call
rc = 1; // Place your own call here e.g., rc = bank_deposit (50); switch(rc) { case 1: lr_end_transaction ("deposit", LR_PASS); break; case 0: lr_end_transaction ("deposit", LR_PASS); break; case -1: lr_end_transaction ("deposit", LR_FAIL); break; }
Example: Output:
Action.c(5): Notify Transaction deposit started.
Action.c(12): Notify Transaction deposit ended with Pass status (Duration: 0.0200).