Repository navigation
Conversation
Prepare to replace print calls and the hand-rolled log file in the decommutator with the logging module. Each module gets a logger named after it, and the package logger gets a NullHandler so that library use emits nothing unless the application configures logging. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Provide one public way to send pyfaradaycup log messages to the console and a log file, usable both from Python and from the command line tool. Handlers are added only to the pyfaradaycup logger, a later call replaces the handlers from an earlier one, and the returned LoggingConfiguration can be closed or used in a with block. Log file timestamps are in UTC. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Library code should only create loggers, so that applications using pyfaradaycup keep control of where log messages go. Use ruff's banned-api rule so that handlers are configured only in pyfaradaycup._logging. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Warnings captured with logging.captureWarnings go to the py.warnings logger rather than the pyfaradaycup logger, so the command line tool needs configure_logging to attach its handlers there too for warnings to reach the console and log file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace print and sys.stdout.write in ccsds_reader_pipeline with logging, so that the reader is silent when used from Python unless logging is configured. Each rejected packet is logged at the DEBUG level with its byte offset, and the number of packets found for each APID and rejected for each reason is logged once at the end, rather than printing one line per packet. The progress display is removed, and the verbose arguments are no longer needed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace _statusmsg and the module-level log file in swp_spc_l0_to_l05 with logging, so that main can be called from Python without writing files or printing, and remove its logdir and verbose arguments. The command line tool now configures logging. Its log file name includes the name of the L0 file and a UTC timestamp, and is opened with mode "x" so that runs cannot overwrite each other's logs. The -v/--verbose option can be repeated to print progress (-v) or details (-vv), -q/--quiet prints only errors, and warnings are printed by default. Warnings about options with no effect and captured Python warnings go to the log file too. An unexpected error is logged with its traceback, and the exit code is 1. Messages that were printed for every rejected packet are logged at the DEBUG level and summarized with one warning per APID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record where each conversion's results came from, so that L0.5 CDF files can be traced back to the inputs and software that made them. main now logs the software versions, host, working directory, and the size and SHA-256 checksum of the L0 file, along with the kernels and skeletons it uses, and logs a summary at the end. main returns a DecommutationResult with the CDF files written, the APIDs that could not be converted and why, the packet counts, and the same provenance, so that Python callers such as a Dagster asset do not need to read log output. pfc_decommutator exits with a code of 1 when any APID could not be converted, including APID 0x07B, which is not implemented. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
namurphy
commented
Oct 29, 2026
Comment on lines
+235
to
+237
| data directory. A summary of the number of packets found for each | ||
| APID is logged, and the reason each packet was rejected is logged | ||
| at the ``DEBUG`` level. |
Member
Author
There was a problem hiding this comment.
I'm wondering if this level of detail is necessary or would actually be helpful. 🤔
Record follow-up work in the decommutator README: writing provenance into the CDF global attributes, comparing CDF attributes in the end-to-end test, and improvements to the log messages, including tagging records with the L0 file and APID, a JSON Lines format, and logging from more than one process. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Napoleon turned the Attributes section into attribute descriptions, and autodoc documented the same dataclass fields again, so a clean documentation build failed with duplicate object warnings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Take the logging implementation and its tests from upstream/main, where configure_logging was merged in PlasmaPy#89, in place of the earlier version on this branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
configure_logging from upstream/main accepts "exclusive" rather than "x" for file_mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The merge took tests/test_logging.py from upstream/main, which does not have the module loggers that this branch adds to the decommutator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Replace the decommutator's hand-rolled log file,
printcalls, andsys.stdout.writeprogress display with theloggingmodule, and addpyfaradaycup.configure_loggingso that logging works the same way from Python and frompfc_decommutator.pyfaradaycuplogger has aNullHandler, so the package is silent from Python unless logging is configured.pyfaradaycup.configure_logging(level=..., log_file=..., file_level=..., file_mode=..., console=..., capture_warnings=...)adds a console handler and a log file handler to thepyfaradaycuplogger only. It returns aLoggingConfiguration, which can be used in awithblock or closed withclose(). Log file timestamps are ISO 8601 in UTC.swp_spc_l0_to_l05.mainno longer takeslogdirorverbose. It logs provenance (software versions, host, working directory, the L0 file's size and SHA-256 checksum, and the kernels and skeletons used) and a summary, and returns aDecommutationResultwith the CDF files written, the APIDs that failed and why, packet counts, and the same provenance.pfc_decommutatorconfigures logging:-vprints progress,-vvprints details, and-qprints only errors. Warnings are printed by default.swp_spc_l0_to_l05_0523462910_4_EA_20261029T190014Z.log. It is opened with mode"x", so runs cannot overwrite each other's logs.DEBUGlevel with the byte offset, and summarized once.pyfaradaycup/_logging.py.Motivation
The decommutator will have both a Python API and a CLI, and will run in a data pipeline. Logging needs to:
This addresses part of "Make it callable from Python" and "Give each run its own log file name" in the decommutator README.
Details
Behavior changes for reviewers to check:
--spacecraft. Previously these runs exited with 0.mainno longer acceptslogdirorverbose, and the private reader functions no longer acceptverbose.ERROR(one was previously a warning). Per-packet IT+ST and APID 0x352 problems are nowDEBUGmessages, plus oneWARNINGsummary per APID.% Complete) has been removed.Not done here:
warnings.warnin_parse_ccsds_headis unchanged.configure_loggingandLoggingConfigurationare not yet in the API docs, becausesphinx.ext.apidocskips private modules andpyfaradaycup/__init__.pyhas no__all__.--spacecraft) path still has no end-to-end test.Tests cover
configure_logging(levels, the file format and UTC timestamps, file modes, closing, replacement, propagation, and capturing warnings), packet rejection logging, the CLI's log file, its exit codes and-v/-q, and a Python API run that checks the result and that nothing is printed. They pass on Python 3.9 and 3.14.🤖 Generated with Claude Code