Skip to content
Permalink
Browse files
docs: add initialization of LogEntry instance in the v2 example (#46)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [X] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-logging/issues/new/choose) before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
- [X] Ensure the tests and linter pass
- [X] Code coverage does not decrease (if any source code was changed)
- [X] Appropriate docs were updated (if necessary)

Fixes #44
  • Loading branch information
ymotongpoo committed Jul 1, 2020
1 parent c5c3c15 commit 251ac9355b192121572552c1c9cfd4df94a42802
Showing with 24 additions and 2 deletions.
  1. +24 −2 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

0 comments on commit 251ac93

Please sign in to comment.