MCPcopy
hub / github.com/serverless/serverless / log

Method log

packages/serverless/lib/plugins/aws/invoke.js:149–194  ·  view source on GitHub ↗
(invocationReply)

Source from the content-addressed store, hash-verified

147 }
148
149 log(invocationReply) {
150 this.progress.remove()
151
152 if (invocationReply.Payload) {
153 const response = JSON.parse(this.payloadToString(invocationReply.Payload))
154
155 writeText(JSON.stringify(response, null, 4))
156 }
157
158 if (invocationReply.LogResult) {
159 this.logger.blankLine()
160 writeText(style.aside('----------------------'))
161 this.logger.blankLine()
162 const logResult = Buffer.from(
163 invocationReply.LogResult,
164 'base64',
165 ).toString()
166 const logResultLines = logResult.split('\n')
167 // Loop through and ensure the log that starts with "START" is always shown first
168 // and the log that starts with "REPORT" is always shown last
169 const startLog = logResultLines.find((line) => line.startsWith('START'))
170 const reportLog = logResultLines.find((line) => line.startsWith('REPORT'))
171 if (startLog) {
172 this.logger.aside(formatLambdaLogEvent(startLog))
173 }
174 logResultLines.forEach((line) => {
175 if (
176 !line.startsWith('START') &&
177 !line.startsWith('END') &&
178 !line.startsWith('REPORT')
179 ) {
180 this.logger.aside(formatLambdaLogEvent(line))
181 }
182 })
183 if (reportLog) {
184 this.logger.aside(formatLambdaLogEvent(reportLog))
185 }
186 }
187
188 if (invocationReply.FunctionError) {
189 throw new ServerlessError(
190 'Invoked function failed',
191 'AWS_LAMBDA_INVOCATION_FAILED',
192 )
193 }
194 }
195}
196
197export default AwsInvoke

Callers 15

constructorMethod · 0.95
optionsMethod · 0.45
emitDisabledLogFunction · 0.45
addVendorHelperFunction · 0.45
removeVendorHelperFunction · 0.45
packRequirementsFunction · 0.45
zipRequirementsFunction · 0.45
layerRequirementsFunction · 0.45
uvToRequirementsFunction · 0.45
generateRequirementsFileFunction · 0.45
installRequirementsFunction · 0.45
filterRequirementsFileFunction · 0.45

Calls 5

payloadToStringMethod · 0.95
writeTextFunction · 0.90
blankLineMethod · 0.80
asideMethod · 0.80
removeMethod · 0.45

Tested by

no test coverage detected