Skip to content

Commit

Permalink
Update logging doc tags. [(#1634)](GoogleCloudPlatform/python-docs-sa…
Browse files Browse the repository at this point in the history
  • Loading branch information
SurferJeffAtGoogle authored and busunkim96 committed Oct 30, 2020
1 parent cd2b128 commit 12bf3da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion samples/snippets/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from google.cloud import logging


# [START logging_list_sinks]
def list_sinks():
"""Lists all sinks."""
logging_client = logging.Client()
Expand All @@ -30,8 +31,10 @@ def list_sinks():

for sink in sinks:
print('{}: {} -> {}'.format(sink.name, sink.filter_, sink.destination))
# [END logging_list_sinks]


# [START logging_create_sink]
def create_sink(sink_name, destination_bucket, filter_):
"""Creates a sink to export logs to the given Cloud Storage bucket.
Expand Down Expand Up @@ -61,8 +64,10 @@ def create_sink(sink_name, destination_bucket, filter_):

sink.create()
print('Created sink {}'.format(sink.name))
# [END logging_create_sink]


# [START logging_update_sink]
def update_sink(sink_name, filter_):
"""Changes a sink's filter.
Expand All @@ -80,9 +85,10 @@ def update_sink(sink_name, filter_):
sink.filter_ = filter_
print('Updated sink {}'.format(sink.name))
sink.update()
# [END update]
# [END logging_update_sink]


# [START logging_delete_sink]
def delete_sink(sink_name):
"""Deletes a sink."""
logging_client = logging.Client()
Expand All @@ -91,6 +97,7 @@ def delete_sink(sink_name):
sink.delete()

print('Deleted sink {}'.format(sink.name))
# [END logging_delete_sink]


if __name__ == '__main__':
Expand Down
6 changes: 6 additions & 0 deletions samples/snippets/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from google.cloud import logging


# [START logging_write_log_entry]
def write_entry(logger_name):
"""Writes log entries to the given logger."""
logging_client = logging.Client()
Expand All @@ -47,8 +48,10 @@ def write_entry(logger_name):
})

print('Wrote logs to {}.'.format(logger.name))
# [END logging_write_log_entry]


# [START logging_list_log_entries]
def list_entries(logger_name):
"""Lists the most recent entries for a given logger."""
logging_client = logging.Client()
Expand All @@ -60,8 +63,10 @@ def list_entries(logger_name):
timestamp = entry.timestamp.isoformat()
print('* {}: {}'.format
(timestamp, entry.payload))
# [END logging_list_log_entries]


# [START logging_delete_log]
def delete_logger(logger_name):
"""Deletes a logger and all its entries.
Expand All @@ -73,6 +78,7 @@ def delete_logger(logger_name):
logger.delete()

print('Deleted all logging entries for {}'.format(logger.name))
# [END logging_delete_log]


if __name__ == '__main__':
Expand Down

0 comments on commit 12bf3da

Please sign in to comment.