stogger.config¶
Configuration handling for stogger.
Classes¶
Detected project layout used for source and test discovery. |
|
Configuration for log format settings, loaded from |
|
Central configuration for stogger, merged from |
Functions¶
|
Detect project structure using smart heuristics. |
Module Contents¶
- class stogger.config.ProjectStructure[source]¶
Detected project layout used for source and test discovery.
- Attributes:
source_dirs: Relative paths to source directories (e.g.
["src"]). test_dirs: Relative paths to test directories (e.g.["tests"]). exclude_patterns: Glob patterns for files excluded from logging analysis. detection_source: How the structure was determined —"pyproject.toml","heuristics", or"defaults".project_root: Absolute path to the project root directory.
- project_root: pathlib.Path¶
- get_source_paths()[source]¶
Resolve source directories to absolute paths.
- Returns:
List of absolute Paths joining
project_rootwith each entry insource_dirs.
- Return type:
- should_exclude_from_logging_analysis(file_path)[source]¶
Check whether a file should be excluded from logging analysis.
Files inside
test_dirsor matching anyexclude_patternsglob are excluded. Files outsideproject_rootare always excluded.- Args:
file_path: Absolute path to the file to check.
- Returns:
Trueif the file should be excluded.
- Parameters:
file_path (pathlib.Path)
- Return type:
- class stogger.config.FormatConfig[source]¶
Configuration for log format settings, loaded from
[tool.stogger.format].- Attributes:
- timestamp_precision: Timestamp format —
"iso","iso_seconds", "iso_no_z", or"relative". Default"iso_seconds".
min_level: Minimum log level to display. Default
"info". show_code_info: Include file name and line number. DefaultFalse. pad_event_width: Minimum width for the event column. Default30.- timestamp_precision: Timestamp format —
- class stogger.config.StoggerConfig(**kwargs)[source]¶
Central configuration for stogger, merged from
[tool.stogger]inpyproject.tomland keyword arguments passed at construction.Key attributes (with defaults):
- Attributes:
verbose (bool): Enable verbose output. Default
False. logdir (Path | None): Directory for log files. DefaultNone. log_cmd_output (bool): Log subprocess command output. DefaultFalse. log_to_console (bool): Also log to the console. DefaultTrue. syslog_identifier (str): Identifier for syslog/systemd journal.Default
"stogger".- show_caller_info (bool): Include caller file/line in log output.
Default
False.- translation_dir (Path | None): Directory containing message
translations. Default
None.
language (str): Language code for log messages. Default
"en". log_format (str): Output format —"simple"or"json".Default
"simple".async_logging (bool): Use asynchronous log writing. Default
False. enable_systemd (bool): Enable systemd/journal integration.Default
True.- systemd_facility (str | None): Syslog facility for systemd output.
Default
None.
src_dir (str): Primary source directory name. Default
"src". format (FormatConfig): Format configuration. DefaultFormatConfig(). ast_respect_gitignore (bool): Honor.gitignoreduring ASTanalysis. Default
True.- ast_max_parameters (int): Max parameters before flagging a function.
Default
8.- ast_logging_focus (bool): Focus AST analysis on logging patterns.
Default
True.- ast_enabled_patterns (list | None): Specific AST patterns to enable.
Noneenables all. DefaultNone.
- Parameters:
kwargs (Any)
- logdir: pathlib.Path | None = None¶
- translation_dir: pathlib.Path | None = None¶
- format: FormatConfig¶
- stogger.config.detect_project_structure(project_root=None)[source]¶
Detect project structure using smart heuristics.
- Args:
project_root: Project root directory. If None, uses current working directory.
- Returns:
ProjectStructure with detected information.
- Raises:
ValueError: If project structure cannot be determined and user configuration is required.
- Parameters:
project_root (pathlib.Path | None)
- Return type: