Skip to content
CCPEDIAby Unity Nodes
App Development

Debug calls in a script - not visible in the logs

2 posts454 views2 likesLast activity Jan 2022

  1. gaborhOP

    I have the following code:

    stuff : Script ()
    stuff = do
        debug "START"
        # do things
        ...
        debug "END"
    

    It prints the debug texts in the “Trace” section in Daml Studio but how is it that I do not see them in the sandbox.log (–log-level DEBUG)?

  2. bernhard 2

    Daml Script does not execute on the Sandbox which represents the ledger, but “client side”, ie in a separate process. You can test this by starting a sandbox using daml sandbox and then running

    > daml script --dar .daml/dist/script-debug-0.0.1.dar --script-name="Main:stuff" --ledger-host=localhost --ledger-port=6865
    [DA.Internal.Prelude:555]: "START"
    [DA.Internal.Prelude:555]: "END"`
    

    If you use daml start, you can also see it after the line “Running the initialization script.”:

    ❯ daml start
    
    2022-01-26 12:32:07.59 [INFO]  [build]
    Compiling script-debug to a DAR.
    
    2022-01-26 12:32:08.12 [INFO]  [build]
    Created .daml/dist/script-debug-0.0.1.dar
    Waiting for sandbox to start:
    13:32:09.155 [sandbox-akka.actor.default-dispatcher-4] INFO  akka.event.slf4j.Slf4jLogger - Slf4jLogger started
    13:32:13.752 [program-resource-pool-1] INFO  c.d.p.apiserver.LedgerApiServer - Listening on localhost:6865 over plain text.
       ____             ____
      / __/__ ____  ___/ / /  ___ __ __
     _\ \/ _ `/ _ \/ _  / _ \/ _ \\ \ /
    /___/\_,_/_//_/\_,_/_.__/\___/_\_\
    
    13:32:13.786 [program-resource-pool-3] INFO  com.daml.platform.sandboxnext.Runner - Initialized sandbox version 2.0.0-snapshot.20211123.8463.0.bd2a6852 with ledger-id = 6a835f73-bf41-4986-a092-069143977b1e, port = 6865, dar file = List(.daml/dist/script-debug-0.0.1.dar), time mode = wall-clock time, ledger = in-memory, auth-service = AuthServiceWildcard$, contract ids seeding = strong
    Running the initialization script.
    [DA.Internal.Prelude:555]: "START"
    [DA.Internal.Prelude:555]: "END"
    Waiting for navigator to start:
       _  __          _           __
      / |/ /__ __  __(_)__ ____ _/ /____  ____
     /    / _ `/ |/ / / _ `/ _ `/ __/ _ \/ __/
    /_/|_/\_,_/|___/_/\_, /\_,_/\__/\___/_/
                     /___/
    Version 2.0.0-snapshot.20211123.8463.0.bd2a6852
    Frontend running at http://localhost:7500.
    

    Edit: Note that none of this requires special log level settings.