From 67a2e250e3ad27d6d0f05e9c662a18c363bd5e1e Mon Sep 17 00:00:00 2001 From: isabel zimmerman Date: Tue, 2 Sep 2025 16:53:05 -0400 Subject: [PATCH] add docs on how to add a logger --- docs/_quarto.yml | 2 ++ docs/logging-pins.qmd | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 docs/logging-pins.qmd diff --git a/docs/_quarto.yml b/docs/_quarto.yml index afb51204..0ca1cfcd 100644 --- a/docs/_quarto.yml +++ b/docs/_quarto.yml @@ -24,6 +24,8 @@ website: menu: - text: "Create consistent metadata for pins" file: customize-pins-metadata.qmd + - text: "Configuring logging for pins" + file: logging-pins.qmd - text: "pins for R" href: https://pins.rstudio.com target: _blank diff --git a/docs/logging-pins.qmd b/docs/logging-pins.qmd new file mode 100644 index 00000000..cc0284b5 --- /dev/null +++ b/docs/logging-pins.qmd @@ -0,0 +1,27 @@ +--- +title: Configuring logging for pins +--- + + +The pins package includes detailed logging that tracks API calls made when reading from or writing to pins boards. This logging is invaluable for debugging connection issues, understanding data flow, and monitoring API usage. To enable and configure logging, you can use Python's built-in `logging` module. + + +```python +import logging + +# Configure pins logger +pins_logger = logging.getLogger('pins') +pins_logger.setLevel(logging.DEBUG) + +# Create console handler +handler = logging.StreamHandler() +handler.setLevel(logging.DEBUG) +pins_logger.addHandler(handler) + +# Now use pins - all API calls will be logged +import pins +``` + +With logging enabled, you'll see detailed information about every HTTP call made to your pins board. This includes the URL, HTTP method, headers, and response status, which can help you diagnose issues quickly. + +You can extend this logger to fit your needs by adding formatters or sending all the logs to a file. To learn more about loggers, see the [Python logging documentation](https://docs.python.org/3/library/logging.html).