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: Update dictConfig snippet #885

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 9 commits into from
Apr 24, 2024
17 changes: 10 additions & 7 deletions 17 samples/snippets/usage_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,33 +486,36 @@ def setup_logging(client):

@snippet
def logging_dict_config(client):
# [START logging_dict_config]
import logging.config

# [START logging_dict_config]
import google.cloud.logging

client = google.cloud.logging.Client()

LOGGING = {
"version": 1,
"handlers": {
"cloud_logging": {
"cloud_logging_handler": {
"class": "google.cloud.logging.handlers.CloudLoggingHandler",
"client": client,
},
"structured_log": {
"structured_log_handler": {
"class": "google.cloud.logging.handlers.StructuredLogHandler"
},
},
"root": {"handlers": ["console"], "level": "WARNING"},
"root": {"handlers": [], "level": "WARNING"},
"loggers": {
"my_logger": {"handlers": ["cloud_logging"], "level": "INFO"},
"my_other_logger": {"handlers": ["structured_log"], "level": "INFO"},
"cloud_logger": {"handlers": ["cloud_logging_handler"], "level": "INFO"},
"structured_logger": {
"handlers": ["structured_log_handler"],
"level": "INFO",
},
},
}
# [END logging_dict_config]

logging.config.dictConfig(LOGGING)
# [END logging_dict_config]


def _line_no(func):
Expand Down
6 changes: 6 additions & 0 deletions 6 samples/snippets/usage_guide_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ def test_client_list_entries():

for item in to_delete:
usage_guide._backoff_not_found(item.delete)


def test_dict_config():
client = Client()

usage_guide.logging_dict_config(client)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.