Skip to content
This repository was archived by the owner on Aug 13, 2026. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a5c36d7
added empty v3.0.0 section to UPGRADING.md
daniel-sanche Dec 7, 2021
0ff7048
reorganized table of contents
daniel-sanche Dec 7, 2021
68e7f9d
marked old handlers as deprecated
daniel-sanche Dec 7, 2021
ff046f5
removed duplicated stdlib doc
daniel-sanche Dec 8, 2021
2e5fd18
made some progress on standard library integration doc
daniel-sanche Dec 8, 2021
51d2a9a
added more stdlib documentation
daniel-sanche Dec 8, 2021
fcc239b
finished up stdlib docs
daniel-sanche Dec 9, 2021
5826ce3
added page for direct API usage
daniel-sanche Dec 9, 2021
205d915
copied old usage guide info
daniel-sanche Dec 9, 2021
98a0a8c
working on setup section
daniel-sanche Dec 10, 2021
117e619
added log writing docs
daniel-sanche Dec 10, 2021
913a08c
removed references to POST requests
daniel-sanche Dec 10, 2021
29ea7d4
added batching info
daniel-sanche Dec 10, 2021
e822bd0
added transport docs
daniel-sanche Dec 10, 2021
8bce609
added grpc vs http docs
daniel-sanche Dec 10, 2021
eac5e2d
added upgrading notes
daniel-sanche Dec 14, 2021
01a0e33
improved manual handler section
daniel-sanche Jan 14, 2022
0526955
fixed lint issues
daniel-sanche Jan 15, 2022
a91b5f4
fixed snippet issue
daniel-sanche Jan 24, 2022
0ad37c8
addressed Drew's comments
daniel-sanche Jan 24, 2022
fd314b9
incorporated Pamela's feedback to migration guide
daniel-sanche Jan 25, 2022
95e5890
updated formatting
daniel-sanche Jan 26, 2022
51a7cd5
updated wording
daniel-sanche Jan 26, 2022
69209b1
changed wording
daniel-sanche Jan 26, 2022
741dfac
addressed Pamela's comments on the direct library usage document
daniel-sanche Jan 26, 2022
49dc3c3
incorporated Pamela's feedback in std lib integration doc
daniel-sanche Jan 26, 2022
ef947d3
removed unneeded delete lines
daniel-sanche Jan 26, 2022
1ff01aa
switched client for tests
daniel-sanche Jan 26, 2022
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
Prev Previous commit
Next Next commit
fixed lint issues
  • Loading branch information
daniel-sanche committed Jan 15, 2022
commit 05269556111ffb7acb00e9c43e689c57104f3105
21 changes: 13 additions & 8 deletions samples/snippets/usage_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ def client_list_entries(client, to_delete): # pylint: disable=unused-argument
@snippet
def client_setup(client2, to_delete):
"""Client setup."""
log_name = "client_setup_%d" % (_millis())

# [START usage_client_setup]
import google.cloud.logging

# if project not given, it will be inferred from the environment
client = google.cloud.logging.Client(project="my-project")
# [END usage_client_setup]
Expand All @@ -116,9 +116,11 @@ def client_setup(client2, to_delete):
# [END usage_http_client_setup]
to_delete.append(http_client)


@snippet
def logger_usage(client_true, to_delete):
"""Logger usage."""
import google.cloud.logging

# [START logger_create]
client = google.cloud.logging.Client(project="my-project")
Expand All @@ -134,6 +136,7 @@ def logger_usage(client_true, to_delete):
to_delete.append(label_logger)
# [START logger_custom_resource]
from google.cloud.logging_v2.resource import Resource

resource = Resource(type="global", labels={})
global_logger = client.logger(log_id, resource=resource)
# [END logger_custom_resource]
Expand All @@ -147,10 +150,11 @@ def logger_usage(client_true, to_delete):
# [END logger_log_basic]

# [START logger_log_fields]
logger.log("an entry with fields set",
logger.log(
"an entry with fields set",
severity="ERROR",
insert_id="0123",
labels={'my-label':'my-value'}
labels={"my-label": "my-value"},
) # API call
# [END logger_log_fields]

Expand Down Expand Up @@ -426,6 +430,7 @@ def logging_handler(client):
handler = CloudLoggingHandler(client, name="mycustomlog")
# [END create_named_handler]


@snippet
def logging_json(client):
# [START logging_json_dumps]
Expand All @@ -443,18 +448,18 @@ def logging_json(client):
logging.info("message field", extra={"json_fields": data_dict})
# [END logging_extra_json_fields]


@snippet
def using_extras(client):
import logging
# [START logging_extras]
my_labels = {"foo": "bar"}
my_http = {"requestUrl": "localhost"}
my_trace = "01234"

logging.info("hello", extra={
"labels": my_labels,
"http_request": my_http,
"trace": my_trace
})
logging.info(
"hello", extra={"labels": my_labels, "http_request": my_http, "trace": my_trace}
)
# [END logging_extras]


Expand Down