refactor(logger): 日志体系优化,分四类文件存储
- 认证日志 (auth.log): 登录/token/监听器注册,target=ias::auth - 消息队列日志 (queue.log): 入队/出队内容、消费路由,target=ias::queue - 工具日志 (tool.log): 调用参数/输出/耗时/工具错误,target=ias::tool - 错误日志 (error.log): 所有非工具调用的 ERROR/WARN 自动捕获 使用 tracing-subscriber 多层过滤架构,终端输出保持不变
This commit is contained in:
+13
-15
@@ -41,8 +41,6 @@
|
||||
|
||||
use reqwest::Client;
|
||||
use std::time::Duration;
|
||||
use tracing::info;
|
||||
|
||||
use crate::tools::types::{RiskLevel, SkillResult, SkillSpec};
|
||||
|
||||
// ═══════════════════════════════════════════════
|
||||
@@ -273,8 +271,8 @@ impl AmapClient {
|
||||
params.push(("waypoints", wp));
|
||||
}
|
||||
|
||||
info!(
|
||||
"parms: {:?}",
|
||||
tracing::info!(target: "ias::tool",
|
||||
"驾车路线请求 parms: {:?}",
|
||||
serde_json::to_string(¶ms).unwrap_or_default()
|
||||
);
|
||||
|
||||
@@ -290,8 +288,8 @@ impl AmapClient {
|
||||
.map_err(|e| format!("解析驾车路线响应失败: {}", e))?;
|
||||
|
||||
if resp["status"].as_str() != Some("1") {
|
||||
info!(
|
||||
"parms: {:?}",
|
||||
tracing::info!(target: "ias::tool",
|
||||
"驾车路线失败 parms: {:?}",
|
||||
serde_json::to_string(&resp).unwrap_or_default()
|
||||
);
|
||||
return Err(format!(
|
||||
@@ -456,7 +454,7 @@ pub async fn poi_search_execute(params: serde_json::Value) -> SkillResult {
|
||||
};
|
||||
|
||||
let result = if let Some(loc) = location {
|
||||
tracing::info!(
|
||||
tracing::info!(target: "ias::tool",
|
||||
"📍 周边搜索: {} @ {} (radius={}m, sort=distance)",
|
||||
keywords,
|
||||
loc,
|
||||
@@ -466,7 +464,7 @@ pub async fn poi_search_execute(params: serde_json::Value) -> SkillResult {
|
||||
.poi_around(keywords, loc, radius, page_num, page_size, "distance")
|
||||
.await
|
||||
} else {
|
||||
tracing::info!("🔍 POI 搜索: {} city={:?}", keywords, city);
|
||||
tracing::info!(target: "ias::tool", "🔍 POI 搜索: {} city={:?}", keywords, city);
|
||||
client
|
||||
.poi_text_search(keywords, city, page_num, page_size)
|
||||
.await
|
||||
@@ -513,7 +511,7 @@ pub async fn geocode_execute(params: serde_json::Value) -> SkillResult {
|
||||
Err(e) => return SkillResult::error(e),
|
||||
};
|
||||
|
||||
tracing::info!("📍 地理编码: {} city={:?}", address, city);
|
||||
tracing::info!(target: "ias::tool", "📍 地理编码: {} city={:?}", address, city);
|
||||
|
||||
match client.geocode(address, city).await {
|
||||
Ok(data) => SkillResult::ok_with_data("✅ 地理编码完成".to_string(), data),
|
||||
@@ -554,7 +552,7 @@ pub async fn reverse_geocode_execute(params: serde_json::Value) -> SkillResult {
|
||||
Err(e) => return SkillResult::error(e),
|
||||
};
|
||||
|
||||
tracing::info!("📍 逆地理编码: {}", location);
|
||||
tracing::info!(target: "ias::tool", "📍 逆地理编码: {}", location);
|
||||
|
||||
match client.regeocode(location).await {
|
||||
Ok(data) => SkillResult::ok_with_data("✅ 逆地理编码完成".to_string(), data),
|
||||
@@ -604,7 +602,7 @@ pub async fn route_plan_execute(params: serde_json::Value) -> SkillResult {
|
||||
Err(e) => return SkillResult::error(e),
|
||||
};
|
||||
|
||||
tracing::info!(
|
||||
tracing::info!(target: "ias::tool",
|
||||
"🛣️ 路径规划: type={}, {} → {}",
|
||||
route_type,
|
||||
origin,
|
||||
@@ -706,7 +704,7 @@ pub async fn travel_plan_execute(params: serde_json::Value) -> SkillResult {
|
||||
Err(e) => return SkillResult::error(e),
|
||||
};
|
||||
|
||||
tracing::info!(
|
||||
tracing::info!(target: "ias::tool",
|
||||
"🗺️ 旅游规划: city={}, interests={:?}, route={}",
|
||||
city,
|
||||
interests,
|
||||
@@ -718,7 +716,7 @@ pub async fn travel_plan_execute(params: serde_json::Value) -> SkillResult {
|
||||
|
||||
// 第一步:搜索各类兴趣点
|
||||
for interest in &interests {
|
||||
tracing::info!("📍 搜索 {}...", interest);
|
||||
tracing::info!(target: "ias::tool", "📍 搜索 {}...", interest);
|
||||
match client.poi_text_search(interest, Some(city), 1, 5).await {
|
||||
Ok(data) => {
|
||||
if let Some(pois) = data["pois"].as_array() {
|
||||
@@ -740,10 +738,10 @@ pub async fn travel_plan_execute(params: serde_json::Value) -> SkillResult {
|
||||
}));
|
||||
}
|
||||
all_pois.extend(pois.clone());
|
||||
tracing::info!(" 找到 {} 个 {}", pois.len(), interest);
|
||||
tracing::info!(target: "ias::tool", " 找到 {} 个 {}", pois.len(), interest);
|
||||
}
|
||||
}
|
||||
Err(e) => tracing::warn!(" 搜索 {} 失败: {}", interest, e),
|
||||
Err(e) => tracing::warn!(target: "ias::tool", " 搜索 {} 失败: {}", interest, e),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user