Log
You can print the runtime logs of the cloud function using the following command. When using this command, you must specify the function name.
# View app function invocation logs
tcb fn log app
Output:
Request time: 2019-08-15 12:12:00
Function name: app
Billing time (ms): 100
Execution time (ms): 0.38
Invocation count: 1
Memory usage: 35.730 MB
Request Id: d451aac7-bf12-11e9-xxxx-525400697544
Invocation status: success
Result: {"Message":"","Time":"2019-08-15T04:12:00Z","TriggerName":"myTrigger","Type":"Timer"}
Logs:
...
END RequestId: d451aac7-bf12-11e9-xxxx-525400697544
Report RequestId: d451aac7-bf12-11e9-xxxx-525400697544 Duration:0ms Memory:256MB MaxMemoryUsed:35.730469MB
By default, the Cloudbase CLI displays the most recent 20 logs. You can specify filter criteria for the returned logs by appending the following available options to the command:
-i, --reqId <reqId> Function request Id
-o, --offset <offset> Data offset. Offset + Limit cannot exceed 10000
-l, --limit <limit> The number of records to return. Offset + Limit cannot exceed 10000
--order <order> Sort logs in ascending or descending order, with optional values 'desc' and 'asc'
--orderBy <orderBy> Sort logs by a field. Supported fields: function_name, duration, mem_usage, start_time
--startTime <startTime> The specific date for querying, for example: 2019-05-16 20:00:00. The time difference between startTime and endtime must be within one day.
--endTime <endTime> The specific date for querying, for example: 2019-05-16 20:59:59. The time difference between endTime and startTime must be within one day.
-e, --error Return only error logs
-s, --success Return only success logs
For example: tcb fn log app -l 2
prints the latest 2 log entries for the app
function
Request time: 2019-08-15 17:04:43
Function name: test-scf
Billing time (ms): 100
Execution time (ms): 0.44
Invocation count: 1
Memory usage: NaN MB
Request Id: 68649b0f-af84-11e9-a803-525400e8849e
Invocation status: success
Result: {"key":"test","userInfo":{"appId":"wx9c4c30a432a38ebc","openId":"on01a6UeSuBLGTQpc_PAjS_RK_4o"}}
Logs: ....