Unable to print on balena log terminal if carriage return is used.

for (auto i = 0; i < 10; ++i) {                            
  std::cout << "\rUpdating : [" << i << "%]" << std::flush;

The above code snippet text does not print anything on the balena log terminal.
I am trying to print on the same line again and again.
Is there a way to solve it.
Balena OS version is 2.48 and supervisor version is 10.8.0


Hello Abhishek, can you expand over your usercase of what you are trying to accomplish by printing on the same line again. Also, If you can also share the Dockerfile, it would help us identify why the snippet doesn’t print anything at all. Maybe the CMD or ENTRYPOINT isn’t specified correctly (Maybe check if a simple Hello World works). Thanks!

Hi Vipul,
I want to display the progress of a process to the users something like below.
Working … [ 60%]
For this, I need to print this on the same line. The number of dots and the percent value will differ. In order to achieve this, I must use carriage return in the cout statement.
Normal Hello World printing works
but it does not work if I place a carriage return at the end like this

Below is my Dockerfile

FROM azure_sdk_main:latest

RUN apt-get -q update && apt-get install -yq --no-install-recommends sqlite3 libsqlite3-dev cmake make libgtest-dev libgoogle-glog-dev && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN cd /usr/src/gtest && cmake . && make && mv /usr/src/gtest/*.a /usr/lib/
COPY . /usr/src/app
ARG run_tests
RUN if [ "$run_tests" = "1" ] ; then make -j6 all_then_test ; else make -j6 ; fi

FROM balenalib/beaglebone-black:buster

ENV DBUS_SYSTEM_BUS_ADDRESS unix:path=/host/run/dbus/system_bus_socket

RUN apt-get -q update && apt-get install -yq --no-install-recommends openssh-client libunwind8 sqlite3 python-dbus libgoogle-glog-dev openssh-server libglib2.0-bin qdbus dbus npm && apt-get clean && rm -rf /var/lib/apt/lists/*

RUN useradd -m fasttemp
RUN chsh -s /bin/bash fasttemp
RUN adduser fasttemp sudo

COPY updateconnection.py /usr
COPY securetty /etc/
COPY Dockerfile autobin.sh startup.sh createiotdevice.js pipe/pipe_init.sh /usr/src/app/

RUN mkdir /var/run/sshd && echo 'fasttemp:4fEmg4CYmY' | chpasswd
COPY ./sshd_config /etc/ssh/sshd_config

WORKDIR /usr/src/app
COPY --from=0 /usr/src/app/binary /usr/src/app/

RUN chmod +x autobin.sh startup.sh pipe_init.sh

CMD ./startup.sh

Hello, a carriage return in a log file does not make sense.
You will not be able to erase the current line in a log file, you can only do it in a terminal.
Lines can only be appended in a log file.

@zvin This makes sense.