Skip to content

Commit ea2b427

Browse files
docs: Added documentation for Django/Flask integrations and dictConfig (#848)
* docs: Added documentation for Django/Flask integrations and dictConfig * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Added product prefix to new snippet * Added client setup in sample + link to settings in documentation * Changed django links to point to `/stable/` links --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 06ad290 commit ea2b427

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

logging/samples/snippets/usage_guide.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,37 @@ def setup_logging(client):
484484
# [END setup_logging_excludes]
485485

486486

487+
@snippet
488+
def logging_dict_config(client):
489+
import logging.config
490+
491+
# [START logging_dict_config]
492+
import google.cloud.logging
493+
494+
client = google.cloud.logging.Client()
495+
496+
LOGGING = {
497+
"version": 1,
498+
"handlers": {
499+
"cloud_logging": {
500+
"class": "google.cloud.logging.handlers.CloudLoggingHandler",
501+
"client": client,
502+
},
503+
"structured_log": {
504+
"class": "google.cloud.logging.handlers.StructuredLogHandler"
505+
},
506+
},
507+
"root": {"handlers": ["console"], "level": "WARNING"},
508+
"loggers": {
509+
"my_logger": {"handlers": ["cloud_logging"], "level": "INFO"},
510+
"my_other_logger": {"handlers": ["structured_log"], "level": "INFO"},
511+
},
512+
}
513+
# [END logging_dict_config]
514+
515+
logging.config.dictConfig(LOGGING)
516+
517+
487518
def _line_no(func):
488519
return func.__code__.co_firstlineno
489520

0 commit comments

Comments
 (0)