mirror of
https://github.com/jorijn/meshcore-stats.git
synced 2026-07-04 00:31:21 +02:00
0f8b0a3492
A Python-based monitoring system for MeshCore LoRa mesh networks. Collects metrics from companion and repeater nodes, stores them in a SQLite database, and generates a static website with interactive SVG charts and statistics. Features: - Data collection from local companion and remote repeater nodes - SQLite database with EAV schema for flexible metric storage - Interactive SVG chart generation with matplotlib - Static HTML site with day/week/month/year views - Monthly and yearly statistics reports (HTML, TXT, JSON) - Light and dark theme support - Circuit breaker for unreliable LoRa connections - Battery percentage calculation from 18650 discharge curves - Automated releases via release-please Live demo: https://meshcore.jorijn.com
32 lines
727 B
Python
32 lines
727 B
Python
"""Simple logging helper."""
|
|
|
|
import sys
|
|
from datetime import datetime
|
|
from .env import get_config
|
|
|
|
|
|
def _ts() -> str:
|
|
"""Get current timestamp string."""
|
|
return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
|
|
def info(msg: str) -> None:
|
|
"""Print info message to stdout."""
|
|
print(f"[{_ts()}] {msg}")
|
|
|
|
|
|
def debug(msg: str) -> None:
|
|
"""Print debug message if MESH_DEBUG is enabled."""
|
|
if get_config().mesh_debug:
|
|
print(f"[{_ts()}] DEBUG: {msg}")
|
|
|
|
|
|
def error(msg: str) -> None:
|
|
"""Print error message to stderr."""
|
|
print(f"[{_ts()}] ERROR: {msg}", file=sys.stderr)
|
|
|
|
|
|
def warn(msg: str) -> None:
|
|
"""Print warning message to stderr."""
|
|
print(f"[{_ts()}] WARN: {msg}", file=sys.stderr)
|