Skip to content

Commit 251ac93

Browse files
authored
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
1 parent c5c3c15 commit 251ac93

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

README.rst

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,31 @@ Using the API
8080
.. code:: python
8181
8282
from google.cloud import logging_v2
83-
8483
client = logging_v2.LoggingServiceV2Client()
85-
entries = []
84+
85+
resource = {
86+
"type": "global",
87+
"labels": {
88+
"project_id": "[PROJECT_ID]"
89+
}
90+
}
91+
92+
"""
93+
Log entries can be either LogEntry or dict.
94+
You can describe the same data in the following format:
95+
96+
e = {
97+
"log_name": "projects/[PROJECT_ID]/logs/test-logging",
98+
"resource": resource,
99+
"text_payload": "this is a log statement",
100+
}
101+
"""
102+
e = logging_v2.types.LogEntry(
103+
log_name="projects/[PROJECT_ID]/logs/test-logging", # optional
104+
resource=resource, # optional
105+
text_payload="this is a log statement")
106+
107+
entries = [e]
86108
response = client.write_log_entries(entries)
87109
88110
.. code:: python

0 commit comments

Comments
 (0)