Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

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

Merged
merged 3 commits into from
Jul 1, 2020
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 26 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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.