Skip to content

Commit

Permalink
Add section on logging in jupyter notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
parejkoj committed Apr 19, 2024
1 parent 17c714c commit fcbcb4f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions stack/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Such a logger can be derived from the module logger using ``log.getChild()``.

Logger names use ``.`` as component separators, not ``::``, even in C++.

.. _basic-python-logging:

Basic Usage in Python
=====================

Expand Down Expand Up @@ -88,6 +90,8 @@ To specify the threshold or the lowest-severity log messages a logger handles, :
logger.setLevel(logging.DEBUG)
.. _basic-c++-logging:

Basic Usage in C++
==================

Expand Down Expand Up @@ -177,6 +181,29 @@ For example, to make the ``calibrate`` stage of ``processCcd`` less verbose:
pipetask --log-level processCcd.calibrate=WARN run [pipeline options]
.. _notebook-logging:

Getting log output in a notebook
================================

The Rubin Science Platform (RSP) automatically configures log output to appear in RSP notebooks via an ipython startup file (``~/.ipython/profile_default/startup/20-logging.py``) that is automatically copied into place if no such file exists.
For stand-alone jupyter notebooks, you have to configure the log output yourself, otherwise log messages will not appear in a notebook.
Running the following code at the start of your notebook will result in output of logs at INFO-level and above:

.. code-block:: python
from lsst.daf.butler.cli.cliLog import CliLog
CliLog.initLog(longlog=False)
Note that if you use the above configuration, you won't get the same logging output as you would with the RSP configuration.

To further configure which logs will appear, set the log level for the ``"lsst"`` namespace as :ref:`described at the end of the python section above <basic-python-logging>` inside your notebook:

.. code-block:: python
import logging
logging.getLogger("lsst").setLevel(logging.DEBUG)
.. _logger-trace-verbosity:

Fine-level Verbosity in Tracing
Expand Down

0 comments on commit fcbcb4f

Please sign in to comment.