0

simple contract compiled using eosio.cdt v1.7.0:

#include <eosiolib/contracts/eosio/eosio.hpp>
#include <eosiolib/core/eosio/print.hpp>

using namespace eosio;

CONTRACT eventhandler : public eosio::contract {

    public:
        using contract::contract;

        ACTION test() {
            print("HELLO WORLD\n");
        }
};

EOSIO_DISPATCH ( eventhandler, (test) )

line to run nodeos:

nodeos -e -p eosio --contracts-console --plugin eosio::producer_plugin --plugin eosio::chain_api_plugin --plugin eosio::http_plugin --plugin eosio::history_api_plugin -d /var/www/blockchain/eosio/data --config-dir /var/www/blockchain/eosio/config --access-control-allow-origin=* --http-validate-host=false

If I use eosio 1.5.7 or lower, the following push...

cleos push action eventhandler test '[]' -p eventhandler

...will generate an output in the console like this:

info  2020-02-10T23:30:54.001 thread-0  producer_plugin.cpp:1556      produce_block        ] Produced block 000000295902c4b5... #41 @ 2020-02-10T23:30:54.000 signed by eosio [trxs: 24, lib: 40, confirmed: 0]
debug 2020-02-10T23:30:54.008 thread-0  apply_context.cpp:28          print_debug          ] 
[(eventhandler,test)->eventhandler]: CONSOLE OUTPUT BEGIN =====================
HELLO WORLD
[(eventhandler,test)->eventhandler]: CONSOLE OUTPUT END   =====================
info  2020-02-10T23:30:55.000 thread-0  producer_plugin.cpp:1556      produce_block        ] Produced block 0000002b9c5bcd55... #42 @ 2020-02-10T23:30:55.000 signed by eosio [trxs: 23, lib: 42, confirmed: 0]

but if I uninstall this eosio version and install eosio v2.0.2, then I execute the same thing but nothing gets printed in the console (apart from the blocks counting)

info  2020-02-10T23:30:57.000 thread-0  producer_plugin.cpp:1556      produce_block        ] Produced block 0000002fa118b688... #47 @ 2020-02-10T23:30:57.000 signed by eosio [trxs: 0, lib: 46, confirmed: 0]
info  2020-02-10T23:30:57.501 thread-0  producer_plugin.cpp:1556      produce_block        ] Produced block 000000300d4de245... #48 @ 2020-02-10T23:30:57.500 signed by eosio [trxs: 0, lib: 47, confirmed: 0]
info  2020-02-10T23:30:58.000 thread-0  producer_plugin.cpp:1556      produce_block        ] Produced block 00000031eff776de... #49 @ 2020-02-10T23:30:58.000 signed by eosio [trxs: 0, lib: 48, confirmed: 0]
info  2020-02-10T23:30:58.501 thread-0  producer_plugin.cpp:1556      produce_block        ] Produced block 0000003228c75c64... #50 @ 2020-02-10T23:30:58.500 signed by eosio [trxs: 0, lib: 49, confirmed: 0]

QUESTIONS:
Am I missing something?
is this output printed somewhere else?
maybe a log file?

1

Contract console out in nodeos log is debug level, but default logging level of nodeos is changed from debug to info. If you want to print console out, put next logging.json in your config directory.

{
  "includes": [],
  "appenders": [{
      "name": "stderr",
      "type": "console",
      "args": {
        "stream": "std_error",
        "level_colors": [{
            "level": "debug",
            "color": "green"
          },{
            "level": "warn",
            "color": "brown"
          },{
            "level": "error",
            "color": "red"
          }
        ]
      },
      "enabled": true
    },{
      "name": "stdout",
      "type": "console",
      "args": {
        "stream": "std_out",
        "level_colors": [{
            "level": "debug",
            "color": "green"
          },{
            "level": "warn",
            "color": "brown"
          },{
            "level": "error",
            "color": "red"
          }
        ]
      },
      "enabled": true
    }
  ],
  "loggers": [{
      "name": "default",
      "level": "debug",
      "enabled": true,
      "additivity": false,
      "appenders": [
        "stderr"
      ]
    },{
      "name": "net_plugin_impl",
      "level": "info",
      "enabled": true,
      "additivity": false,
      "appenders": [
        "stderr"
      ]
    },{
      "name": "http_plugin",
      "level": "info",
      "enabled": true,
      "additivity": false,
      "appenders": [
        "stderr"
      ]
    },{
      "name": "producer_plugin",
      "level": "info",
      "enabled": true,
      "additivity": false,
      "appenders": [
        "stderr"
      ]
    },{
      "name": "transaction_tracing",
      "level": "info",
      "enabled": true,
      "additivity": false,
      "appenders": [
        "stderr"
      ]
    }
  ]
}
  • awesome @conr2d, thx! – cmadh Feb 13 at 13:53
  • @cmadh My pleasure :) – conr2d 2 days ago
0

Not sure why this happens, but I've also been struggling with it.

I get around it by doing

eosio::print("hello!");
eosio::check(false, "uh oh");

So when I do cleos push action ... it then errors out the transaction, but prints "hello!" in the console.

Would also love to know a better way to print, but for now maybe this could help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.