DAML Template - Trace/Debug/Logging

Hi Everyone!!

Is there a way to log values from the template/choice into a log file.

choice Iou_Split : (IouCid, IouCid)
        with
        splitAmount: Decimal
      controller owner
      do
        let restAmount = amount - splitAmount
        splitCid <- create this with amount = splitAmount
        restCid <- create this with amount = restAmount
        return (splitCid, restCid)

Can anyone help, how could I log “splitCid” value into log for better understanding.

Thanks!

Hi @prajwalhegde3 :wave:

I think you can use debug to print the value.

1 Like

@nemanja : Thanks for the response.

But still kind of confused. I have added the debug statements in my choice and have checked the canton and sandbox logs, can’t find what I’m looking for.

May be an example and advice which log file to refer would be helpful.

Thank you!

Hi @prajwalhegde3 :wave:

How are you executing the choice? Are you using Daml script or REPL to test the workflow?

1 Like

Hi @nemanja

For now executing the choice through the Navigator app.

So you need to start the sandbox with debugging enabled

When I run the sandbox like this:

daml start --sandbox-option --debug I get the output in the default log location ( log/canton.log)

Note that if there are errors in your code and the execution doesn’t reach your debug statement you won’t see the output.

1 Like

Thank you @nemanja

1 Like