Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usage question #6

Open
petergdoyle opened this issue Sep 26, 2015 · 1 comment
Open

usage question #6

petergdoyle opened this issue Sep 26, 2015 · 1 comment

Comments

@petergdoyle
Copy link

Cool package!
Can you suggest the most efficient way to clear line content that has been left from previous outputs please?
I am believing that (in this case) it is more efficient for me to use newline characters rather than jump around from line to line with Jetty.
This needs to keep up with a very fast message queue and I want to add the least amount of overhead to the program.
Maybe I am not understanding clearLine(), but it does not seem to work to clear the line if I included it before or after the line output.

// Clear the screen
jetty.clear();
jetty.moveTo([0,0]);
jetty.text("Stats for Kafka Topic '"+consumer_topic+"'");

consumer.on('message', function (message) {

  total_bytes+=message.value.length;
  count++;
  avg_size = total_bytes / count;
  jetty.moveTo([1,0]);
  jetty.text(
    'total_messages: '.concat(numeral(count,'0 a'))
    +'\navg_msg_size: '.concat(numeral(avg_size).format('0.00 b'))
    +'\ntotal_msg_volume: '.concat(numeral(total_bytes).format('0.00 b'))
    +'\n');
  jetty.clearLine();

});

This always yields something like this (below) once the line content has changed in length (and you see at one point the KB was the unit of measure and now switched to MB). I want to get rid of the last line output overflow (without having to keep track of last line length and padding with spaces or something).

Stats for Kafka Topic 'sentences'
total_messages: 43927
avg_msg_size: 353.76 B
total_msg_volume: 14.82 MBKB
@petergdoyle
Copy link
Author

Sorry ! I closed the wrong issue (from another project).
Can you please take a look ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant