* Add RDLog::CaptureLog for capturing log messages
Adds an RAII `CaptureLog` class to `namespace RDLog` (alongside the
existing `LogStateSetter`) that redirects an RDKit logger's output to an
internal `std::stringstream` for the duration of its lifetime. On
destruction the original stream destination and enabled state are fully
restored. Nesting is supported: an inner capture shadows the outer one
and each collects its own messages independently.
The default constructor captures `rdErrorLog`; an explicit constructor
accepts any `RDLogger`. Both enable the logger if it was previously
disabled and restore that state on destruction.
Python bindings expose `rdBase.CaptureLog` as a context manager with a
`messages` read-only property, mirroring the existing `rdBase.BlockLogs`
pattern. Messages remain accessible after the `with` block exits.
C++ tests are added to `catch_logs.cpp` (6 Catch2 sections covering
basic capture, empty state, enable/restore, stream restore, explicit
logger, and nested captures). Python tests are added to
`UnitTestLogging.py` (6 unittest cases covering the same scenarios).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* CaptureLog: add per-level properties (error_messages, warning_messages, etc.)
The Python CaptureLog wrapper now captures all four log levels
simultaneously. Per-level properties (error_messages, warning_messages,
info_messages, debug_messages) give access to messages from each logger
independently; the existing messages property returns them all combined.
The C++ RDLog::CaptureLog class is unchanged — it remains a clean
single-logger RAII type. The Python wrapper composes four instances of
it, one per log level.
Suggested by bp-kelley in PR review.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Refactor CaptureLog: add named per-level subclasses
Add CaptureErrorLog, CaptureWarningLog, CaptureInfoLog, and CaptureDebugLog
as named convenience subclasses of CaptureLog, each capturing a specific
logger. Update Python bindings to expose the four named classes directly
(dropping the combined multi-capture approach), and update tests accordingly.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Simplify CaptureLog: no argument, captures rdErrorLog only
Remove the RDLogger argument overload, the four named subclasses, and the
PyCaptureLog template in favor of a single no-argument CaptureLog that
mirrors the Schrödinger CaptureRDErrorLog from which it was inspired.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* CaptureLog tests: add dp_dest restoration and LogStateSetter interaction
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Rename CaptureLog to CaptureErrorLog
The name CaptureLog was ambiguous; CaptureErrorLog is explicit about which
logger it captures and avoids redundancy within namespace RDLog.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Generalize CaptureErrorLog into CaptureLog with logger parameter
Replace CaptureErrorLog with CaptureLog, which accepts any RDLogger in
its constructor (e.g. rdErrorLog, rdWarningLog). Add CaptureErrorLog as
a convenience subclass that pre-fills rdErrorLog, preserving backward
compatibility for existing callers.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
* expose RDLog to SWIG wrappers
* - added a SetTee() overload that takes a filename as parameter to simplify redirecting from wrappers that do not have interface with C++ streams (e.g., Java and C#)
- replaced some duplicate code with ClearTee() calls
- replaced RDLogger std::shared_ptr with boost::shared_ptr to make it more easily available from SWIG wrappers
- exposed the RDLogger methods to SWIG wrappers
- added Java test for RDLogger
* this should fix the segfault
* avoid issues on case-insensitive platforms
* here's a solution keeping std:;shared_ptr
* change in response to review
---------
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
* add test
* fix LogStateSetter
* fix BlockLogs() usage in Draw module
* allow BlockLogs() as a contestmgr
* move test to more suitable location
* guarantee log restoration on __exit__
* skip test if logs cannot be grabbed before block
* disable the info and debug logs by default
* adjust tests to the newly disabled logs
* add LogStateSetter
* namespace reorg
* add some tests
* remove vestigial code
* switch to using std::vector