scitex.logging API Reference
- scitex.logging.getLogger(name=None)[source]
Return a logger with the specified name, creating it if necessary.
If no name is specified, return the root logger.
- scitex.logging.configure(level='info', log_file=None, enable_file=True, enable_console=True, capture_prints=True, max_file_size=10485760, backup_count=5)[source]
Configure logging for SciTeX with both console and file output.
- Parameters:
level (
Union[str,int]) – Log level (string or logging constant)log_file (
Optional[str]) – Path to log file (default: ~/.scitex/logs/scitex-YYYY-MM-DD.log)enable_file (
bool) – Whether to enable file loggingenable_console (
bool) – Whether to enable console loggingcapture_prints (
bool) – Whether to capture print() statements to logsmax_file_size (
int) – Maximum size of log file before rotation (default: 10MB)backup_count (
int) – Number of backup files to keep (default: 5)
- scitex.logging.tee(sys, sdir=None, verbose=True)[source]
Redirects stdout and stderr to both console and log files.
Example
>>> import sys >>> sys.stdout, sys.stderr = tee(sys) >>> print("abc") # stdout >>> print(1 / 0) # stderr
- scitex.logging.log_to_file(file_path, level=10, mode='w', formatter=None)[source]
Context manager to temporarily log all output to a specific file.
- Usage:
import scitex_logging as logging logger = logging.getLogger(__name__)
- with logging.log_to_file(“/path/to/log.txt”):
logger.info(“This goes to both console and /path/to/log.txt”) logger.success(“This too!”)
- Parameters:
- Yields:
The file handler (can be ignored)
- exception scitex.logging.SciTeXWarning[source]
Bases:
UserWarningBase warning class for all SciTeX warnings.
- exception scitex.logging.UnitWarning[source]
Bases:
SciTeXWarningWarning for axis label unit issues (educational for SI conventions).
Raised when: - Axis labels are missing units - Units use parentheses instead of brackets (SI prefers []) - Units use division instead of negative exponents (m/s vs m·s⁻¹)
- exception scitex.logging.StyleWarning[source]
Bases:
SciTeXWarningWarning for style/formatting issues.
- exception scitex.logging.SciTeXDeprecationWarning[source]
Bases:
SciTeXWarningWarning for deprecated SciTeX features.
- exception scitex.logging.PerformanceWarning[source]
Bases:
SciTeXWarningWarning for performance issues.
- exception scitex.logging.DataLossWarning[source]
Bases:
SciTeXWarningWarning for potential data loss.
- scitex.logging.warn(message, category=<class 'scitex_logging._warnings.SciTeXWarning'>, stacklevel=2)[source]
Emit a warning (like warnings.warn but integrated with scitex.logging).
- Parameters:
- Return type:
Examples
>>> import scitex.logging as logging >>> from scitex.logging import UnitWarning >>> logging.warn("X axis has no units", UnitWarning)
- scitex.logging.filterwarnings(action, category=<class 'scitex_logging._warnings.SciTeXWarning'>, message=None)[source]
Control warning behavior (like warnings.filterwarnings).
- Parameters:
action (str) – One of: - “ignore”: Never show this warning - “error”: Raise as exception - “always”: Always show - “default”: Show first occurrence per location - “once”: Show only once total - “module”: Show once per module
category (type) – Warning category (default: SciTeXWarning = all)
message (str, optional) – Regex pattern to match warning message (not implemented yet)
- Return type:
Examples
>>> import scitex.logging as logging >>> from scitex.logging import UnitWarning >>> logging.filterwarnings("ignore", category=UnitWarning)
- scitex.logging.warn_deprecated(old_name, new_name, version=None)[source]
Issue a deprecation warning.
- Return type:
- scitex.logging.warn_performance(operation, suggestion)[source]
Issue a performance warning.
- Return type:
- exception scitex.logging.SciTeXError(message, context=None, suggestion=None)[source]
Bases:
ExceptionBase Exception class for all SciTeX errors.
- exception scitex.logging.ConfigurationError(message, context=None, suggestion=None)[source]
Bases:
SciTeXErrorRaised when there are issues with SciTeX configuration.
- exception scitex.logging.ConfigFileNotFoundError(filepath)[source]
Bases:
ConfigurationErrorRaised when a required configuration file is not found.
- exception scitex.logging.ConfigKeyError(key, available_keys=None)[source]
Bases:
ConfigurationErrorRaised when a required configuration key is missing.
- exception scitex.logging.IOError(message, context=None, suggestion=None)[source]
Bases:
SciTeXErrorBase class for input/output related errors.
- exception scitex.logging.FileFormatError(filepath, expected_format=None, actual_format=None)[source]
Bases:
IOErrorRaised when file format is not supported or incorrect.
- exception scitex.logging.SaveError(filepath, reason)[source]
Bases:
IOErrorRaised when saving data fails.
- exception scitex.logging.LoadError(filepath, reason)[source]
Bases:
IOErrorRaised when loading data fails.
- exception scitex.logging.ScholarError(message, context=None, suggestion=None)[source]
Bases:
SciTeXErrorBase class for scholar module errors.
- exception scitex.logging.SearchError(query, source, reason)[source]
Bases:
ScholarErrorRaised when paper search fails.
- exception scitex.logging.EnrichmentError(paper_title, reason)[source]
Bases:
ScholarErrorRaised when paper enrichment fails.
- exception scitex.logging.PDFDownloadError(url, reason)[source]
Bases:
ScholarErrorRaised when PDF download fails.
- exception scitex.logging.DOIResolutionError(doi, reason)[source]
Bases:
ScholarErrorRaised when DOI resolution fails.
- exception scitex.logging.PDFExtractionError(filepath, reason)[source]
Bases:
ScholarErrorRaised when PDF text extraction fails.
- exception scitex.logging.BibTeXEnrichmentError(bibtex_file, reason)[source]
Bases:
ScholarErrorRaised when BibTeX enrichment fails.
- exception scitex.logging.TranslatorError(translator_name, reason)[source]
Bases:
ScholarErrorRaised when Zotero translator operations fail.
- exception scitex.logging.AuthenticationError(provider, reason='')[source]
Bases:
ScholarErrorRaised when authentication fails.
- exception scitex.logging.PlottingError(message, context=None, suggestion=None)[source]
Bases:
SciTeXErrorBase class for plotting-related errors.
- exception scitex.logging.FigureNotFoundError(fig_id)[source]
Bases:
PlottingErrorRaised when attempting to operate on a non-existent figure.
- exception scitex.logging.AxisError(message, axis_info=None)[source]
Bases:
PlottingErrorRaised when there are issues with plot axes.
- exception scitex.logging.DataError(message, context=None, suggestion=None)[source]
Bases:
SciTeXErrorBase class for data processing errors.
- exception scitex.logging.ShapeError(expected_shape, actual_shape, operation)[source]
Bases:
DataErrorRaised when data shapes are incompatible.
- exception scitex.logging.DTypeError(expected_dtype, actual_dtype, operation)[source]
Bases:
DataErrorRaised when data types are incompatible.
- exception scitex.logging.PathError(message, context=None, suggestion=None)[source]
Bases:
SciTeXErrorBase class for path-related errors.
- exception scitex.logging.InvalidPathError(path, reason)[source]
Bases:
PathErrorRaised when a path is invalid or doesn’t follow SciTeX conventions.
- exception scitex.logging.PathNotFoundError(path)[source]
Bases:
PathErrorRaised when a required path doesn’t exist.
- exception scitex.logging.TemplateError(message, context=None, suggestion=None)[source]
Bases:
SciTeXErrorBase class for template-related errors.
- exception scitex.logging.TemplateViolationError(filepath, violation)[source]
Bases:
TemplateErrorRaised when SciTeX template is not followed.
- exception scitex.logging.NNError(message, context=None, suggestion=None)[source]
Bases:
SciTeXErrorBase class for neural network module errors.
- exception scitex.logging.ModelError(model_name, reason)[source]
Bases:
NNErrorRaised when there are issues with neural network models.
- exception scitex.logging.StatsError(message, context=None, suggestion=None)[source]
Bases:
SciTeXErrorBase class for statistics module errors.
- exception scitex.logging.TestError(test_name, reason)[source]
Bases:
StatsErrorRaised when statistical tests fail.