AMOS 增加 info 级别日志追踪数据流
- weather_sources.py: _attach_korean_amos_data 记录 fetch 开始、成功/失败、温度/跑道数据 - amos_station_sources.py: _amos_get_page 记录页面匹配/不匹配 - amos_station_sources.py: fetch_amos_official_current 记录 HTML 获取和解析 - analysis_service.py: _analyze 记录 AMOS 数据是否到达分析层 重启后端后在日志中搜索 "AMOS" 可追踪完整数据流: AMOS: fetching for city=seoul AMOS page matched icao=RKSI length=... AMOS fetch_amos_official_current: got HTML for RKSI... AMOS: got data for city=seoul temp_c=... source=... AMOS _analyze: found amos data for city=seoul temp_c=...
This commit is contained in:
@@ -384,12 +384,13 @@ class AmosStationSourceMixin:
|
||||
return None
|
||||
|
||||
if text and re.search(rf"\({icao}\)|\b(?:METAR|TAF)\s+{icao}\b", text, re.I):
|
||||
logger.info("AMOS page matched icao={} length={}", icao, len(text))
|
||||
record_source_call("amos", "page", "success", (time.perf_counter() - started) * 1000.0)
|
||||
return text
|
||||
logger.debug("AMOS page did not expose requested airport {}", icao)
|
||||
logger.warning("AMOS page did not expose requested airport {} (tried {} urls)", icao, len(urls))
|
||||
return None
|
||||
except Exception as exc:
|
||||
logger.debug("AMOS page fetch failed icao={}: {}", icao, exc)
|
||||
logger.warning("AMOS page fetch failed icao={}: {}", icao, exc)
|
||||
record_source_call("amos", "page", "error", (time.perf_counter() - started) * 1000.0)
|
||||
return None
|
||||
|
||||
@@ -419,8 +420,11 @@ class AmosStationSourceMixin:
|
||||
try:
|
||||
html = self._amos_get_page(icao)
|
||||
if not html:
|
||||
logger.warning("AMOS fetch_amos_official_current: no HTML for {}", icao)
|
||||
return None
|
||||
|
||||
logger.info("AMOS fetch_amos_official_current: got HTML for {} ({} chars), parsing METAR/runway", icao, len(html))
|
||||
|
||||
# Parse METAR line
|
||||
icao_pattern = re.escape(icao)
|
||||
metar_match = re.search(rf"METAR\s+{icao_pattern}\s.*?=", html, re.DOTALL)
|
||||
|
||||
@@ -879,13 +879,19 @@ class WeatherDataCollector(OpenMeteoCacheMixin, SettlementSourceMixin, MetarSour
|
||||
if city_lower not in ("seoul", "busan"):
|
||||
return
|
||||
try:
|
||||
logger.info("AMOS: fetching for city={}", city_lower)
|
||||
amos_data = self.fetch_amos_official_current(
|
||||
city_lower, use_fahrenheit=use_fahrenheit
|
||||
)
|
||||
if amos_data:
|
||||
logger.info("AMOS: got data for city={} temp_c={} source={} runway_pairs={}",
|
||||
city_lower, amos_data.get("temp_c"), amos_data.get("temp_source"),
|
||||
len(amos_data.get("runway_obs", {}).get("runway_pairs", []) or []))
|
||||
results["amos"] = amos_data
|
||||
else:
|
||||
logger.warning("AMOS: no data returned for city={}", city_lower)
|
||||
except Exception as exc:
|
||||
logger.debug("AMOS attach failed city={}: {}", city_lower, exc)
|
||||
logger.warning("AMOS attach failed city={}: {}", city_lower, exc)
|
||||
|
||||
def _attach_russia_official_nearby(
|
||||
self, results: Dict, city_lower: str, use_fahrenheit: bool
|
||||
|
||||
@@ -1733,6 +1733,9 @@ def _analyze(
|
||||
mg_cur = mgm.get("current", {}) if mgm else {}
|
||||
sc_cur = settlement_current.get("current", {}) if settlement_current else {}
|
||||
amos_data = raw.get("amos") or {}
|
||||
if amos_data:
|
||||
logger.info("AMOS _analyze: found amos data for city={} temp_c={} source={}",
|
||||
city, amos_data.get("temp_c"), amos_data.get("source"))
|
||||
use_settlement_current = settlement_source in {"hko", "cwa", "noaa", "wunderground"} and bool(sc_cur)
|
||||
live_mc = mc if metar_current_is_today else {}
|
||||
primary_current = sc_cur if use_settlement_current else live_mc
|
||||
|
||||
Reference in New Issue
Block a user