You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Differentiate sls invoke response from logging to allow piping result #4675
problem:
when you run sls invoke, both the invocation response and logs are written to the console with console.log (stdout). This makes it hard to differentiate the invocation response from logging, and makes piping the command impossible.
potential solutions:
log to stderr, write the invocation response to stdout.
accept an --output option, and write the response to the provided file path
Reacted by Matt Gibson, Travis Vignon, Huon Wilson, Greg Najda, Mariusz Nowak and Shalvah
changed the title [-]differentiate invoke response from invoke logging to allow piping result[/-][+]differentiate sls invoke response from loggins to allow piping result[/+]on Jan 22, 2018
changed the title [-]differentiate sls invoke response from loggins to allow piping result[/-][+]differentiate sls invoke response from logging to allow piping result[/+]on Jan 22, 2018
We should fix the correct output stream for errors to stderr (see my comment in #4673 )
However, the log output belongs to one or the other depending on the log level, e.g. informational logs belong to stdout while error logs do not.
As the results that are logged are in fact data outputs, they should go into stdout (as is), but additionally having --output|-o to redirect the data output would be very beneficial.
@HyperBrain i agree, writing all logs to stderr would be morally wrong :) my vote's for --output as well.
in the current code, invoke output isn't handled in any centralized fashion - there are just console logs sprinkled around. Are there are plans to? It doesn't seem hard to handle --output for invoke, and for invoke local on Node.js. However, the output from local python and java lambdas doesn't seem differentiated
changed the title [-]differentiate sls invoke response from logging to allow piping result[/-][+]Differentiate sls invoke response from logging to allow piping result[/+]on Feb 13, 2019
We're hitting this somewhat, we're invoking a function and expecting a JSON response, but there's a serverless warning, so the stdout "JSON" is:
Serverless Warning --------------------------------------A valid environment variable to satisfy the declaration 'env:XYZ' could not be found.
{
"success": true
}
And this is of course not valid JSON, breaking our later processing. We're fixing the warning, but a pipeline doing something else isn't our preferred place to be informed of a warning.
However, the log output belongs to one or the other depending on the log level, e.g. informational logs belong to stdout while error logs do not.
I'm not convinced of this: I think the stderr name is deceptive and it shouldn't just be "error logs go here", but everything that isn't part of the data output. stdout would be completely junked up by INFO and DEBUG level logs (when enabled), even if WARNING and ERROR level logs are going to stderr.
Activity
[-]differentiate invoke response from invoke logging to allow piping result[/-][+]differentiate sls invoke response from loggins to allow piping result[/+][-]differentiate sls invoke response from loggins to allow piping result[/-][+]differentiate sls invoke response from logging to allow piping result[/+]HyperBrain commentedon Jan 22, 2018
We should fix the correct output stream for errors to stderr (see my comment in #4673 )
However, the log output belongs to one or the other depending on the log level, e.g. informational logs belong to stdout while error logs do not.
As the results that are logged are in fact data outputs, they should go into stdout (as is), but additionally having
--output|-oto redirect the data output would be very beneficial.mvayngrib commentedon Jan 22, 2018
@HyperBrain i agree, writing all logs to stderr would be morally wrong :) my vote's for
--outputas well.in the current code,
invokeoutput isn't handled in any centralized fashion - there are just console logs sprinkled around. Are there are plans to? It doesn't seem hard to handle--outputforinvoke, and forinvoke localon Node.js. However, the output from local python and java lambdas doesn't seem differentiated[-]differentiate sls invoke response from logging to allow piping result[/-][+]Differentiate sls invoke response from logging to allow piping result[/+]huonw commentedon Jan 5, 2021
We're hitting this somewhat, we're invoking a function and expecting a JSON response, but there's a serverless warning, so the
stdout"JSON" is:And this is of course not valid JSON, breaking our later processing. We're fixing the warning, but a pipeline doing something else isn't our preferred place to be informed of a warning.
I'm not convinced of this: I think the
stderrname is deceptive and it shouldn't just be "error logs go here", but everything that isn't part of the data output.stdoutwould be completely junked up byINFOandDEBUGlevel logs (when enabled), even ifWARNINGandERRORlevel logs are going tostderr.medikoo commentedon Dec 7, 2021
Closing as it's fixed with #9860