geotrax.utils.logging_utils¶
The logger behind every geotrax command: colored console output, a log file per run in a platform-native folder, and a NOTICE level for messages that should be visible without --verbose. Use it for the loggers you pass to the other helpers.
setup_logger
¶
setup_logger(name: str, verbose: bool = False, log_path: str | Path | None = None, dry_run: bool = False) -> Logger
Create the logger that every geo-trax command uses: colored console output plus a log file.
The console shows NOTICE and above (INFO and above when verbose); the file always records INFO
and above. The first call also starts a non-blocking, cached check for a newer geo-trax on PyPI
(disable it with GEOTRAX_DISABLE_UPDATE_CHECK=1). Each call adds handlers, so create a
logger once per name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Logger name; its last dotted component also names the auto-named log file. |
required |
verbose
|
bool
|
Show INFO messages on the console too. |
False
|
log_path
|
str | Path | None
|
Where to write the log. A directory, existing or not, gets an auto-named
|
None
|
dry_run
|
bool
|
Log to the console only, without a file. |
False
|
Returns:
| Type | Description |
|---|---|
Logger
|
The configured logger, which also has a |
Examples:
logger = setup_logger("my_analysis", verbose=True, dry_run=True)
logger.notice("Shown without --verbose.")
Source code in geotrax/utils/logging_utils.py
default_log_dir
¶
Return the platform-native directory for geo-trax log files.
Returns:
| Type | Description |
|---|---|
Path
|
|
Source code in geotrax/utils/logging_utils.py
NOTICE_LEVEL
module-attribute
¶
Custom level between INFO and WARNING, shown on the console without --verbose; logged with logger.notice(...).