scitex_core.logging
- scitex_core.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_core.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)
- class scitex_core.logging.Tee(stream, log_path_or_stream, verbose=True)[source]
Bases:
object- property buffer
- scitex_core.logging.tee(sys_or_path=None, sdir=None, verbose=True)[source]
Tee stdout/stderr to files.
Two calling styles are supported:
tee(sys_module, sdir=None)— the legacy call that returns(stdout_tee, stderr_tee)wrappingsys.stdout/sys.stderr.tee(path)— context-manager form that redirectssys.stdoutto aTeewriting to both the original stdout andpath.
Example
>>> with tee("/tmp/out.log"): ... print("hello") # printed + logged to /tmp/out.log
- scitex_core.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:
from scitex import 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)
- scitex_core.logging.__DIR__ = '/home/ywatanabe/proj/scitex-core/src/scitex_core/logging'
Modular logging utilities for SciTeX.
This module provides enhanced logging capabilities with both console and file output, ensuring consistent logging across the SciTeX package.
- Migration:
# OLD (deprecated) from scitex import logging logger = logging.getLogger(__name__)
# NEW (recommended) from scitex import logging logger = logging.getLogger(__name__)
- Usage:
from scitex import logging # DEPRECATED logger = logging.getLogger(__name__) logger.success(“Operation completed successfully”) logger.fail(“Operation failed”)
# Configure logging with file output logging.configure(level=’info’, enable_file=True)
# Get current log file location log_file = logging.get_log_path()