dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

Improve logging #245

Open Alxandr opened 7 years ago

Alxandr commented 7 years ago

Currently logging is only a simple log command. This has to be improved somehow, as it's too limiting. For instance, I can't log two things on the same line (Starting compilation... DONE).

The most versatile solution is probably just to expose a WritableStream, then other logging functionality can be built on top of that.

ORESoftware commented 6 years ago

what kind of logging? debugging logging?

Alxandr commented 6 years ago

No. Output to the console logging. As in, when I'm writing a console application, I would like to be able to output things to the console.

ORESoftware commented 6 years ago

sorry then you are going to have to be more specific, as in, what is wrong with console.log()

Alxandr commented 6 years ago

Well, it's a bit hard to answer after months of not looking at vorpal, but IIRC the issue is that vorpal uses custom streams of output for the commands. It has its own stdout/stdin, which allows you to do piping within vorpal. Whether or not console.log works or not, I don't remember. But I do remember that I couldn't use console.log, because it inserts a newline at the end, and I needed to be able to print things that doesn't include a newline.

ORESoftware commented 6 years ago

right, so try process.stdout.write('foo') if you don't want a newline.

console.log() / process.stdout.write() will work with Vorpal

if you want something to go to the terminal, it usually has to go to process.stdout or process.stderr in the end anyway

Alxandr commented 6 years ago

Not if you're doing internal piping. Then it has to be redirected to the next command.

ORESoftware commented 6 years ago

best to show some code demonstrating the problem at this point

Alxandr commented 6 years ago

Yeah, as said, I don't even have the project I had this problem with anymore. This was the main reason I changed away from vorpal. But, if I recall correctly the issue is as following:

If you create 2 commands in vorpal, let's call them write and read. write writes to stdout, whereas read reads from stdin. Then you launch the vorpal interactive mode, and you type in write | read. The issue is that I need to output content that does not end in a linefeed from write, that is then read by read.