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

Commit 70d9d25

Browse filesBrowse files
authored
docs: Added documentation on log_level and excluded_loggers params in setup_logging (#971)
* docs: Added documentation on log_level and excluded_loggers params in setup_logging * Added product prefix to new region tags.
1 parent 681bcc5 commit 70d9d25
Copy full SHA for 70d9d25

File tree

4 files changed

+23
-6
lines changed
Filter options

4 files changed

+23
-6
lines changed

‎docs/std-lib-integration.rst

Copy file name to clipboardExpand all lines: docs/std-lib-integration.rst
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ call :meth:`~google.cloud.logging_v2.client.Client.setup_logging` on a :class:`~
1616
:end-before: [END logging_handler_setup]
1717
:dedent: 4
1818

19+
20+
You can also set the logging level threshold of the logging handler created by :meth:`~google.cloud.logging_v2.client.Client.setup_logging`,
21+
as well as set loggers excluded from the logger that is created:
22+
23+
.. literalinclude:: ../samples/snippets/usage_guide.py
24+
:start-after: [START logging_setup_logging]
25+
:end-before: [END logging_setup_logging]
26+
:dedent: 4
27+
28+
.. literalinclude:: ../samples/snippets/usage_guide.py
29+
:start-after: [START logging_setup_logging_excludes]
30+
:end-before: [END logging_setup_logging_excludes]
31+
:dedent: 4
32+
33+
1934
This :meth:`~google.cloud.logging_v2.client.Client.setup_logging` function chooses the best configurations for the environment your
2035
code is running on. For more information, see the `Google Cloud Logging documentation <https://cloud.google.com/logging/docs/setup/python>`_.
2136

‎google/cloud/logging_v2/client.py

Copy file name to clipboardExpand all lines: google/cloud/logging_v2/client.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ def setup_logging(
400400
loggers, will report to Cloud Logging.
401401
402402
Args:
403-
log_level (Optional[int]): Python logging log level. Defaults to
403+
log_level (Optional[int]): The logging level threshold of the attached logger,
404+
as set by the :meth:`logging.Logger.setLevel` method. Defaults to
404405
:const:`logging.INFO`.
405406
excluded_loggers (Optional[Tuple[str]]): The loggers to not attach the
406407
handler to. This will always include the

‎google/cloud/logging_v2/handlers/handlers.py

Copy file name to clipboardExpand all lines: google/cloud/logging_v2/handlers/handlers.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ def setup_logging(
296296
excluded_loggers (Optional[Tuple[str]]): The loggers to not attach the handler
297297
to. This will always include the loggers in the
298298
path of the logging client itself.
299-
log_level (Optional[int]): Python logging log level. Defaults to
299+
log_level (Optional[int]): The logging level threshold of the attached logger,
300+
as set by the :meth:`logging.Logger.setLevel` method. Defaults to
300301
:const:`logging.INFO`.
301302
"""
302303
all_excluded_loggers = set(excluded_loggers + _INTERNAL_LOGGERS)

‎samples/snippets/usage_guide.py

Copy file name to clipboardExpand all lines: samples/snippets/usage_guide.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,13 @@ def using_extras(client):
475475
def setup_logging(client):
476476
import logging
477477

478-
# [START setup_logging]
478+
# [START logging_setup_logging]
479479
client.setup_logging(log_level=logging.INFO)
480-
# [END setup_logging]
480+
# [END logging_setup_logging]
481481

482-
# [START setup_logging_excludes]
482+
# [START logging_setup_logging_excludes]
483483
client.setup_logging(log_level=logging.INFO, excluded_loggers=("werkzeug",))
484-
# [END setup_logging_excludes]
484+
# [END logging_setup_logging_excludes]
485485

486486

487487
@snippet

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.