Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,31 @@ Using the API
.. code:: python

from google.cloud import logging_v2

client = logging_v2.LoggingServiceV2Client()
entries = []
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though this PR only changed the issue that the list entries is empty, I think we need to add how to set resources and log_name. What do you think?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that would be useful to have too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I added the note.


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
Expand Down