-
Notifications
You must be signed in to change notification settings - Fork 27
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
Console logs from imported modules in AWS template file #18
Comments
Thanks @RafalBDS. I'm not sure I should do anything about it in the way cloudform currently operates. Note that outputting the template via the stdout stream is the core API part of cloudform. If you decide to put something more into stdout from your code, then yes, it will also be included in the output, by definition. Option I consider is to play with process's streams and ensure your I'd suggest using |
Also, I'm not sure what do you mean about this part of the issue:
Could you please clarify? |
@NOtherDev |
I'm actually quite surprised this issue turned out to not be an issue :) Given the following code
I wouldn't expect "Hello" to be printed out. I'm explicitly exporting an object created by cloudform and running it through
@NOtherDev could you please elaborate why this is the case? |
All I said is that cloudform CLI does not create a template file for you. It outputs it to stdout and it's your code that writes it to the file, normally via stream redirection. So whatever you output to the stream from your code will land there. We might consider creating output file by cloudform itself as an option (or as the way to go by default in next major). I can't see how can we overcome this in any other sane way. Do you? |
What I was thinking about is to suppress any stout/stderr output printed by executing the template file. IMHO the readme hints pretty clearly that one should use Had the export not be required it would be more easy to understand that |
OK, but on the other hand, if you explicitly do |
I agree that suppressing it completely could be surprising as well 🤔 How about redirecting all writes performed during template loading to stderr? This could be as follows:
Then the standard |
It's still the same type of confusion. Why stderr when you wrote to stdout? |
I agree that this is more easy to follow
Because stdout, as documented, is what cloudform uses. The example suggest that you need to do Why is |
Valid question. It is not. Just let me find some spare time, we'll have it in v3.6. |
Writing to stdout can be helpful when you try to pipe CLI commands, so I believe that the current approach should stay the default. Given the miensol example, the easy solution is to use the SDK approach instead of the CLI, and write the file manually in the code. In which case, you definitely expect to see your "console.log('Generating template')" and "console.log('Saving template') in stdout. |
I'm submitting a...
Current behavior
Expected behavior
Console logs of imported modules should be printed to console, instead of aws template
Minimal reproduction of the problem with instructions
Create a module which has one function that console.log something. Import it to cloudform template. Generate aws template - your console log will be in the first line
What is the motivation / use case for changing the behavior?
It is usefull to import some types/interfaces from modules - this issue disallows such option
Environment
The text was updated successfully, but these errors were encountered: