Open blaskovicz opened 4 years ago
I guess it's better to just implement a API to read the statistics (see #8)? Then people can develop their own code to log the status to console.
I'll leave it open for discussion.
About item 2 (work target descriptions): the worker can update the url
property of the complex object you passed as data, and it will display as the worker description. It doesn't need to be an actual url at all. It just needs to be a string, as you can see here in the source.
https://github.com/thomasdondorf/puppeteer-cluster/blob/fbd9a9f8f9c2c889e145b6af8c2bd3fa28ec4bf6/src/Job.ts#L31-L42
It's kind of hacky but... well, it works for me. Displaying descriptions is essential in my case because each of my workers performs a long-running, multiple step task. And here's the output.
You can even use ANSI color escape codes.
data.url = '\033[33m Doing step 1 \033[39m';
For non-interactive (eg: batch) environments where puppeteer-cluster is used, it would be nice to enhance the display of statistics to be more friendly:
Example output:
Ideally, there would be 3 enhancements made (listed in order of request priority):
1) ability to aggregate display output (for example, when tasks change state or on some interval) 1) ability to set custom work target descriptions (eg: for when the data passed to a task is a non-string (code here); 1) ability to detect non-interactive terminal and avoid outputting terminal escape sequences