Log() does not print anything in emulator

I was trying to test out moving tokens between accounts, very ad-hoc and basic stuff on emulator network to get the hang of the language. When it came time to check for my account’s Vault Balance, I wrote a short script that prints the balance attribute of the Vault but it would not print anything to the console.

So I wrote the following script to test if log prints anything at all:

pub fun main() {
log(“Hello World”)

and then I type the following command into the CLI

flow scripts execute ./scripts/test.cdc

and this is the output:

Version warning: a new version of Flow CLI is available (v0.27.0).
Read the installation guide for upgrade instructions: https://docs.onflow.org/flow-cli/install

Result: ()

Why is nothing being typed on the console? Is it normal to expect nothing to print on emulator? If I can’t get log to work, how can I check if my contracts and transactions worked properly?

Thanks and I apologize for the bad formatting, I’m not very good at this.

Update: Ok I realized that I can’t print to the Terminal in VScode so I just edited the function like this:

pub fun main(): UFix64 {
    *** Do stuff here ***
    return VaultReference.balance

and my account’s balance is returned to the terminal.

When using the CLI, try using the -v flag. That might show the logs

1 Like