Files
ai_english/serve/scripts/test_log_format.sh
2025-11-17 13:39:05 +08:00

42 lines
1.0 KiB
Bash
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 测试日志格式脚本
# 用于演示新的emoji日志格式
echo "🧪 测试后端日志格式"
echo "================================"
echo ""
BASE_URL="http://localhost:8080"
echo "1⃣ 测试健康检查 (GET 200)"
curl -s "$BASE_URL/health" > /dev/null
sleep 1
echo "2⃣ 测试登录 (POST 200)"
curl -s -X POST "$BASE_URL/api/v1/auth/login" \
-H "Content-Type: application/json" \
-d '{"account":"test@example.com","password":"Test@123"}' > /dev/null
sleep 1
echo "3⃣ 测试404错误 (GET 404)"
curl -s "$BASE_URL/api/v1/not-found" > /dev/null
sleep 1
echo "4⃣ 测试OPTIONS预检 (OPTIONS 204)"
curl -s -X OPTIONS "$BASE_URL/api/v1/user/profile" \
-H "Origin: http://localhost:3001" > /dev/null
sleep 1
echo "5⃣ 测试未授权 (GET 401)"
curl -s "$BASE_URL/api/v1/user/profile" > /dev/null
sleep 1
echo ""
echo "✅ 测试完成!"
echo "📋 查看日志:"
echo " tail -20 logs/app.log"
echo ""
echo "🎨 格式化查看需要安装jq"
echo " tail -20 logs/app.log | jq '.'"