Skip to content

Commit edcff80

Browse files
committed
Merge pull request GoogleCloudPlatform#209 from danasmera/master
Fix KeyError exception when project has no logs
2 parents 6da2b63 + a41a72d commit edcff80

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

cloud_logging/api/list_logs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
# [START all]
2727
import argparse
28+
import sys
2829

2930
from googleapiclient import discovery
3031
from oauth2client.client import GoogleCredentials
@@ -36,6 +37,9 @@ def list_logs(project_id, logging_service):
3637

3738
while request:
3839
response = request.execute()
40+
if not response:
41+
print("No logs found in {0} project").format(project_id)
42+
return False
3943
for log in response['logs']:
4044
print(log['name'])
4145

0 commit comments

Comments
 (0)