vorpal icon indicating copy to clipboard operation
vorpal copied to clipboard

Improve logging

Open Alxandr opened this issue 7 years ago • 8 comments

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.

Alxandr avatar Jun 02 '17 16:06 Alxandr

what kind of logging? debugging logging?

ORESoftware avatar Nov 06 '17 01:11 ORESoftware

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.

Alxandr avatar Nov 06 '17 07:11 Alxandr

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

ORESoftware avatar Nov 06 '17 07:11 ORESoftware

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.

Alxandr avatar Nov 06 '17 07:11 Alxandr

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

ORESoftware avatar Nov 06 '17 07:11 ORESoftware

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

Alxandr avatar Nov 06 '17 08:11 Alxandr

best to show some code demonstrating the problem at this point

ORESoftware avatar Nov 06 '17 08:11 ORESoftware

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.

Alxandr avatar Nov 06 '17 09:11 Alxandr