| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 669733c commit d43503c
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,21 @@ call :meth:`~google.cloud.logging_v2.client.Client.setup_logging` on a :class:`~ | |||
| 16 | 16 | :end-before: [END logging_handler_setup] | |
| 17 | 17 | :dedent: 4 | |
| 18 | 18 | ||
| 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 | + | ||
| 19 | 34 | This :meth:`~google.cloud.logging_v2.client.Client.setup_logging` function chooses the best configurations for the environment your | |
| 20 | 35 | code is running on. For more information, see the `Google Cloud Logging documentation <https://cloud.google.com/logging/docs/setup/python>`_. | |
| 21 | 36 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -400,7 +400,8 @@ def setup_logging( | |||
| 400 | 400 | loggers, will report to Cloud Logging. | |
| 401 | 401 | ||
| 402 | 402 | 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 | ||
| 404 | 405 | :const:`logging.INFO`. | |
| 405 | 406 | excluded_loggers (Optional[Tuple[str]]): The loggers to not attach the | |
| 406 | 407 | handler to. This will always include the | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -296,7 +296,8 @@ def setup_logging( | |||
| 296 | 296 | excluded_loggers (Optional[Tuple[str]]): The loggers to not attach the handler | |
| 297 | 297 | to. This will always include the loggers in the | |
| 298 | 298 | 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 | ||
| 300 | 301 | :const:`logging.INFO`. | |
| 301 | 302 | """ | |
| 302 | 303 | all_excluded_loggers = set(excluded_loggers + _INTERNAL_LOGGERS) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -475,13 +475,13 @@ def using_extras(client): | |||
| 475 | 475 | def setup_logging(client): | |
| 476 | 476 | import logging | |
| 477 | 477 | ||
| 478 | - # [START setup_logging] | ||
| 478 | + # [START logging_setup_logging] | ||
| 479 | 479 | client.setup_logging(log_level=logging.INFO) | |
| 480 | - # [END setup_logging] | ||
| 480 | + # [END logging_setup_logging] | ||
| 481 | 481 | ||
| 482 | - # [START setup_logging_excludes] | ||
| 482 | + # [START logging_setup_logging_excludes] | ||
| 483 | 483 | client.setup_logging(log_level=logging.INFO, excluded_loggers=("werkzeug",)) | |
| 484 | - # [END setup_logging_excludes] | ||
| 484 | + # [END logging_setup_logging_excludes] | ||
| 485 | 485 | ||
| 486 | 486 | ||
| 487 | 487 | @snippet | |
| Back | FazBrowse Home | New Git URL |
0 commit comments