Cloud Function Logs
Use the tcb fn log command to view cloud function execution logs.
Basic Usage
tcb fn log <functionName>
Usage Example:
# View invocation logs for app function
tcb fn log app
Command Parameters
By default, CLI returns the most recent 20 logs. You can filter and paginate using the following parameters:
| Parameter | Description | Notes |
|---|---|---|
-i, --reqId <reqId> | Function request ID | Exact query |
-l, --limit <limit> | Number of records to return | Offset + Limit cannot exceed 10000 |
-o, --offset <offset> | Data offset | Offset + Limit cannot exceed 10000 |
--order <order> | Sort order | Options: desc(descending), asc(ascending) |
--orderBy <orderBy> | Sort field | Supports: function_name, duration, mem_usage, start_time |
--startTime <startTime> | Query start time | Format: 2019-05-16 20:00:00, interval with endTime cannot exceed 1 day |
--endTime <endTime> | Query end time | Format: 2019-05-16 20:59:59, interval with startTime cannot exceed 1 day |
-e, --error | Return only error logs | - |
-s, --success | Return only successful logs | - |
Usage Examples
# View latest 2 logs
tcb fn log app -l 2
# View logs within specified time range
tcb fn log app --startTime "2019-05-16 20:00:00" --endTime "2019-05-16 20:59:59"
# View only error logs
tcb fn log app -e
# Sort by execution duration in descending order
tcb fn log app --orderBy duration --order desc
# Query logs for specific request ID
tcb fn log app -i d451aac7-bf12-11e9-xxxx-525400697544
Log Output Example
Request time: 2019-08-15 12:12:00
Function name: app
Billing duration(ms): 100
Execution duration(ms): 0.38
Invocation count: 1
Memory usage: 35.730 MB
Request ID: d451aac7-bf12-11e9-xxxx-525400697544
Invocation status: Success
Return 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
Important Notes
- Default returns the most recent 20 logs
- Offset + Limit cannot exceed 10000
- The interval between startTime and endTime cannot exceed 1 day