add debug flag to 'plural cd services lua' command#670
Conversation
michaeljguarino
left a comment
There was a problem hiding this comment.
Isn't print a lua built-in? I think all we need is to ensure it actually gets sent to os stdout. This is fine if it works, just seems like it might not be necessary
|
@michaeljguarino but we want to display stdout conditionally, depending on the debug flag, right? |
|
Stdout is now captured and shown only when debugging is enabled |
michaeljguarino
left a comment
There was a problem hiding this comment.
I actually don't fully grok what this is doing. Is the idea that you're directing stdout to the pipe (which is going to receive the lua print built-ins) and then only actually printing it if debug is enabled?
|
Generally, yes, so the question is, how should it work? |
|
Should I add extra Go print, for example: |
|
The way it should work is any invocation of |
|
Exactly, the Lua engine sends the output of the built-in print function to stdout, so the issue was a bit misleading for me because I didn’t understand why the --debug flag was needed. I’ll take a closer look and try to reproduce the problem. If you have a faulty script that demonstrates this issue, it would be very helpful |
Summary
This PR updates the Lua state initialization to register a custom print() function that writes all Lua output to a Go bytes.Buffer. This allows capturing printed output from Lua scripts for debugging
Labels
Test Plan
Checklist