Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add initialization of LogEntry instance in the v2 example #46

Merged
merged 3 commits into from Jul 1, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 25 additions & 3 deletions README.rst
@@ -1,7 +1,7 @@
Python Client for Stackdriver Logging
=====================================

|pypi| |versions|
|pypi| |versions|

`Stackdriver Logging API`_: Writes log entries and manages your Stackdriver
Logging configuration.
Expand Down Expand Up @@ -82,9 +82,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