Skip to content

Commit

Permalink
docs: add initialization of LogEntry instance in the v2 example (#46)
Browse files Browse the repository at this point in the history
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 251ac93
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions README.rst
Expand Up @@ -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
Expand Down

0 comments on commit 251ac93

Please sign in to comment.