diff --git a/README.rst b/README.rst index d41b0232..2399e08b 100644 --- a/README.rst +++ b/README.rst @@ -80,9 +80,31 @@ Using the API .. code:: python from google.cloud import logging_v2 - client = logging_v2.LoggingServiceV2Client() - entries = [] + + resource = { + "type": "global", + "labels": { + "project_id": "[PROJECT_ID]" + } + } + + """ + Log entries can be either LogEntry or dict. + You can describe the same data in the following format: + + e = { + "log_name": "projects/[PROJECT_ID]/logs/test-logging", + "resource": resource, + "text_payload": "this is a log statement", + } + """ + e = logging_v2.types.LogEntry( + log_name="projects/[PROJECT_ID]/logs/test-logging", # optional + resource=resource, # optional + text_payload="this is a log statement") + + entries = [e] response = client.write_log_entries(entries) .. code:: python