Interactive TUI and non-interactive CLI helper for exploring SmarterMail logs on Linux servers
Project description
sm-logtool
sm-logtool is a terminal-first log explorer for SmarterMail logs. It ships
with:
- A Textual wizard UI (
browse) for interactive searching. - A console search command (
search) for quick scripted checks. - Log staging that copies or unzips source logs before analysis.
- Conversation/entry grouping for supported SmarterMail log kinds.
- Syntax-highlighted results in both TUI and CLI output.
- Live progress, execution mode, and cancel support for long TUI searches.
- Parallel multi-target search with safe serial fallback when needed.
Requirements
- Python 3.10+
- Linux (project classifiers currently target POSIX/Linux)
Deployment Model
sm-logtool does not require installation on the same host as SmarterMail,
but it is designed for that workflow. In practice, you typically SSH to the
mail server and run searches there.
The tool stages logs into a separate working directory so the original SmarterMail logs remain untouched during analysis and sub-searches.
Install
Install from PyPI (recommended):
pipx install sm-logtool
Alternative with pip:
python -m pip install sm-logtool
This installs the sm-logtool command.
Update
Update an existing install from PyPI:
pipx upgrade sm-logtool
# or
python -m pip install --upgrade sm-logtool
If you use the fuzzy-search speedup extra, update with extras:
pipx install --force "sm-logtool[speedups]"
# or
python -m pip install --upgrade "sm-logtool[speedups]"
Recommended Speedups (Strongly Recommended)
For significantly better fuzzy-search performance, install with the optional
speedups extra:
pipx install "sm-logtool[speedups]"
# or
python -m pip install "sm-logtool[speedups]"
sm-logtool automatically uses the accelerator when available and
automatically falls back to the built-in matcher when it is not installed.
Skipping this extra can materially reduce fuzzy-search responsiveness and
overall usability on large logs.
Configuration
Configuration is YAML with these keys:
logs_dir: source SmarterMail logs directory.staging_dir: working directory used for copied/unzipped logs.default_kind: default log kind (for examplesmtp).theme: Textual UI theme name (for exampleCyberdark,Cybernotdark, ortextual-dark). Results syntax highlighting follows the selected UI theme palette and theme name.
Example:
logs_dir: /var/lib/smartermail/Logs
staging_dir: /var/tmp/sm-logtool/logs
default_kind: smtp
theme: Cyberdark
Repository template:
config.example.yamlis a sample config for local bootstrap.- The repository does not track a live runtime
config.yaml.
Bootstrap a per-user config from the template:
mkdir -p ~/.config/sm-logtool
cp config.example.yaml ~/.config/sm-logtool/config.yaml
If staging_dir does not exist yet, the app creates it automatically.
On startup and quit, staged files older than 14 days are pruned
automatically.
Default config location is per-user:
~/.config/sm-logtool/config.yaml
Config resolution order:
--config /path/to/config.yamlSM_LOGTOOL_CONFIG~/.config/sm-logtool/config.yaml
When the default path is used and the file does not exist, sm-logtool
creates it automatically with SmarterMail-oriented defaults.
Usage
Top-level help:
sm-logtool --help
sm-logtool --version
Launch the TUI
sm-logtool
# or
sm-logtool browse --logs-dir /var/lib/smartermail/Logs
Browse Mode Workflow
Wizard flow:
- Choose log kind.
- Select one or more log dates. Today is selected by default; deselect it if unwanted.
- Enter search term and choose search mode
(
Literal/Wildcard/Regex/Fuzzy) plus result mode (Show all related traffic/Only matching rows). - Review results, copy selection/all, and optionally run sub-search. Right-click on results to open copy actions.
Core actions are always visible in the top action strip:
Ctrl+QquitCtrl+Rreset search stateCtrl+Uopen command palette/menu
Search-step footer shortcuts:
Ctrl+Ffocus search inputCtrl+Leftprevious search modeCtrl+Rightnext search modeCtrl+Upincrease fuzzy threshold (fuzzy mode only)Ctrl+Downdecrease fuzzy threshold (fuzzy mode only)
Clipboard note:
- Results copy actions use terminal clipboard protocol (OSC 52). Clipboard support depends on your terminal/multiplexer chain configuration.
Date selection shortcuts:
- Arrow keys to move
- Click to toggle a date
Spaceto toggle a dateEnterto select the highlighted date and continue- Today is selected by default when the date step opens
Run console search
sm-logtool search --kind smtp --date 2024.01.01 "example.com"
Minimum examples:
# Search newest log for default_kind from config.yaml (default: smtp)
sm-logtool search "somebody@example.net"
# Search newest delivery log
sm-logtool search --kind delivery "somebody@example.net"
# Wildcard mode: '*' any chars, '?' single char
sm-logtool search --mode wildcard "Login failed: User * not found"
# Regex mode: Python regular expression
sm-logtool search --mode regex "Login failed: User \\[(sales|billing)\\]"
# Fuzzy mode: approximate matching with configurable threshold
sm-logtool search --mode fuzzy --fuzzy-threshold 0.72 \
"Authentcation faild for user [sales]"
# Result mode: only show direct matching rows
sm-logtool search --result-mode matching-only "blocked"
Target resolution:
- If
--log-fileis provided (repeatable), those files are searched. - Else if
--dateis provided (repeatable), those dates are searched. - Else the newest available log for
--kindis searched.
Search options:
--logs-dir: source logs directory. Optional whenlogs_diris set in the active config file.--staging-dir: staging directory. Optional whenstaging_diris set in the active config file.--kind: log kind. Optional whendefault_kindis set in the active config file.--date:YYYY.MM.DDdate to search. Repeat to search multiple dates.--log-file: explicit file to search. Repeat to search multiple files.--list: list available logs for the selected kind and exit.--list-kinds: list supported kinds and exit.--mode: search mode (literal,wildcard,regex, orfuzzy).--fuzzy-threshold: similarity threshold for--mode fuzzyfrom0.00to1.00(default0.75).--result-mode: output mode (relatedormatching-only).related(default) shows full grouped traffic for matched identifiers.--case-sensitive: disable default case-insensitive matching.
Search mode behavior:
literal: exact substring matching (default).wildcard:*matches any sequence and?matches one character.regex: Pythonresyntax (PCRE-like, but not full PCRE).fuzzy: approximate line matching using a similarity threshold. Installingsm-logtool[speedups]is strongly recommended for this mode.
Result mode behavior:
related: show full grouped conversations for matched identifiers (default).matching-only: show only rows that directly match the search term.
Regex checker note:
- If an online regex builder does not offer Python mode, use PCRE/PCRE2 and stick to common features; some PCRE-only constructs may not work.
Convert Terminal Themes (Visual Utility)
Use the built-in visual converter:
sm-logtool themes --source ~/.config/sm-logtool/theme-sources
Theme file locations (per-user):
- Source theme files to import:
~/.config/sm-logtool/theme-sources - Converted themes saved by Theme Studio:
~/.config/sm-logtool/themes - Both directories are created automatically on first run of
sm-logtool browseorsm-logtool themes.
These locations are user-home paths, so imported/converted themes are local user settings, not repository files.
Theme Studio workflow:
- Supported source files:
.itermcolors,.colors,.colortheme. - Toggle mapping profiles (
balanced/vivid/soft) in the UI and preview both chrome and syntax colors live before saving. - Toggle ANSI-256 quantization in the UI for non-truecolor terminals.
- Click preview elements to select a mapping target, then:
[/]cycle mapping source (auto, semantic colors,ansi0..ansi15)-/=cycle mapping targetcclear current override
- Selection-row states are auto-corrected before save so
Selected,Active, andSelected+Activeremain distinct. sm-logtool browseauto-loads saved converted themes from that directory.- Safety: when using
--configorSM_LOGTOOL_CONFIG, in-app theme switching does not auto-write the config file.
Testing with a temporary config (recommended for development):
sm-logtool --config /tmp/sm-logtool-test.yaml themes
sm-logtool --config /tmp/sm-logtool-test.yaml browse
Supported Log Kinds
Search handlers currently exist for:
smtp,imap,popdeliveryadministrativeimapretrievalactivation,autocleanfolders,calendars,contentfilter,event,generalerrors,indexing,ldap,maintenance,profiler,spamchecks,webdav
Log discovery expects SmarterMail-style names such as:
YYYY.MM.DD-kind.log or YYYY.MM.DD-kind.log.zip.
Development
Install with test, lint, and type-check tooling:
python -m pip install -e ".[test,lint,typecheck]"
Run standards checks quickly:
python -m pytest -q test/test_line_length_policy.py \
test/test_public_docstrings.py
Run lint checks before running tests:
python -m ruff check .
Run static type checks:
python -m mypy sm_logtool
Run the full test suite with both frameworks used in this repository:
pytest -q
python -m unittest discover test
Additional Docs
License
This project is licensed under AGPL-3.0. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sm_logtool-1.0.2.tar.gz.
File metadata
- Download URL: sm_logtool-1.0.2.tar.gz
- Upload date:
- Size: 115.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a647018daac1ac25c2c2927250fd8918c74ed2b2ed8e646091d322a657117999
|
|
| MD5 |
1cbe3300e14937bfbe75efe8a29e01d3
|
|
| BLAKE2b-256 |
14bb998320387eab08f42337bb6de48acd8560ce8f5c95a87773998ac3d9c2ca
|
Provenance
The following attestation bundles were made for sm_logtool-1.0.2.tar.gz:
Publisher:
publish.yml on T313C0mun1s7/sm-logtool
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sm_logtool-1.0.2.tar.gz -
Subject digest:
a647018daac1ac25c2c2927250fd8918c74ed2b2ed8e646091d322a657117999 - Sigstore transparency entry: 1373212887
- Sigstore integration time:
-
Permalink:
T313C0mun1s7/sm-logtool@04bdcb1424a92edce6c5ab46bedf39f77a6fb14f -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/T313C0mun1s7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@04bdcb1424a92edce6c5ab46bedf39f77a6fb14f -
Trigger Event:
release
-
Statement type:
File details
Details for the file sm_logtool-1.0.2-py3-none-any.whl.
File metadata
- Download URL: sm_logtool-1.0.2-py3-none-any.whl
- Upload date:
- Size: 94.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b4bbe2eb4c83288660d0a5c850f71ae31567614601464dacb5a4f3b588f9a55
|
|
| MD5 |
4aeb7bc9c2757b9d23bef582a0fae21a
|
|
| BLAKE2b-256 |
de140979e64e36140b0e62978d5529bbcdc9fcd3886b738a34cdbd10e26e9de7
|
Provenance
The following attestation bundles were made for sm_logtool-1.0.2-py3-none-any.whl:
Publisher:
publish.yml on T313C0mun1s7/sm-logtool
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sm_logtool-1.0.2-py3-none-any.whl -
Subject digest:
2b4bbe2eb4c83288660d0a5c850f71ae31567614601464dacb5a4f3b588f9a55 - Sigstore transparency entry: 1373212961
- Sigstore integration time:
-
Permalink:
T313C0mun1s7/sm-logtool@04bdcb1424a92edce6c5ab46bedf39f77a6fb14f -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/T313C0mun1s7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@04bdcb1424a92edce6c5ab46bedf39f77a6fb14f -
Trigger Event:
release
-
Statement type: