Can't print within remote tasks C++ API

Hi all,

I’m having issues getting the console output from print statements that are inside the remote tasks. This is my code:

#include <ray/api.h>

class Counter
{
public:

    int index;

    Counter(int init)
    {
        index = init;
    }
    static Counter *FactoryCreate(int init) { return new Counter(init); }

    void print(int init)
    {
        std::cout << "Print index: " << init <<"\n";
    }
};

RAY_REMOTE(Counter::FactoryCreate, &Counter::print);

int main(int argc, char **argv)
{
    ray::Init();

    std::vector<ray::ObjectRef<void>> actors;

    for (int i = 0; i < 10; i++)
    {
        ray::ActorHandle<Counter> actor = ray::Actor(Counter::FactoryCreate).Remote(i);
        actors.push_back(actor.Task(&Counter::print).Remote(i));
    }
    ray::Shutdown();
    return 0;
}

I saw other people reporting similar issues with the python API, but the replies weren’t helpful in solving my problem. Any idea what I’m doing wrong?

Thanks!

Can you try RAYLOG(INFO) << "Print index: " << init;

Thanks for the reply. Yeah, I tried the solution you suggested, but still no output. Is RAYLOG supposed to write to a file?