feat: complete logging audit - fill all gaps

- Filter noisy audio play() errors from frontend log
- Add logging to ALL 8 ToBet services (was only Baccarat)
- Add InitTableService logging (Sumday/Boot/NumberTab creation & failure)
- Add logview.sh for quick log viewing
- Add log_cleanup.sh for 30-day rotation
This commit is contained in:
testadmin
2026-05-14 11:49:36 +08:00
parent 7fe15a0d50
commit a180fe8385
10 changed files with 124 additions and 6 deletions
+4
View File
@@ -3,6 +3,7 @@
namespace app\services\bet;
use app\models\bet\Bet;
use app\utils\Logger;
use freedom\utils\DiceUtil;
use freedom\utils\SocketSession;
@@ -33,6 +34,7 @@ class ToBetDiceService{
$time = time();
$toBetCheck = ToBetCommonService::toBetCheck($tableInfo,$event,$data);
if ($toBetCheck['status'] == false){
Logger::warn(Logger::CAT_BET, 'dice_bet_fail', ['table_id' => $tableInfo['id'], 'msg' => $toBetCheck['msg']]);
$ws->emit('toBet',['status' => false, 'table_id' => $tableInfo['id'], 'msg' => $toBetCheck['msg']]);
SocketSession::resetRepeat($fd,'user','isToBet');
return;
@@ -90,6 +92,7 @@ class ToBetDiceService{
$res = Bet::toBet($tableInfo,$userInfo,$numberTabInfo,$prevBetInfo,$data,$seat_num,$betTotalAmount,$time,0);
$numberTabAmount = string_to_array($numberTabInfo['dice_amount']);
if($res){
Logger::info(Logger::CAT_BET, 'dice_bet_success', ['user_id' => $userInfo['id'], 'table_id' => $tableInfo['id'], 'amount' => $amount]);
$ws->emit('toBet',['status' => true, 'table_id' => $tableInfo['id'], 'bet_amount_msg' => $betTotalAmount, 'money' => ($userInfo['money'] - $amount),'seat_num' => $seat_num, 'msg' => 'to_bet_success']);
$totalAmountArray = DiceUtil::amountInc($numberTabAmount, $data);
$round = [
@@ -98,6 +101,7 @@ class ToBetDiceService{
];
$ws->to(SocketSession::HOUSE_NAME)->emit('allBetAmount',['status' => true, 'table_id' => $tableInfo['id'], 'round' => $round]);
}else{
Logger::warn(Logger::CAT_BET, 'dice_bet_db_fail', ['user_id' => $userInfo['id'], 'table_id' => $tableInfo['id'], 'amount' => $amount]);
$ws->emit('toBet',['status' => false, 'table_id' => $tableInfo['id'], 'msg' => 'to_bet_fail']);
}
SocketSession::resetRepeat($fd,'user','isToBet');
+4
View File
@@ -5,6 +5,7 @@ namespace app\services\bet;
use app\models\bet\Bet;
use app\utils\Logger;
use freedom\utils\SocketSession;
/**
@@ -32,6 +33,7 @@ class ToBetDtService
$time = time();
$toBetCheck = ToBetCommonService::toBetCheck($tableInfo,$event,$data);
if ($toBetCheck['status'] == false){
Logger::warn(Logger::CAT_BET, 'dt_bet_fail', ['table_id' => $tableInfo['id'], 'msg' => $toBetCheck['msg']]);
$ws->emit('toBet',['status' => false, 'table_id' => $tableInfo['id'], 'msg' => $toBetCheck['msg']]);
SocketSession::resetRepeat($fd,'user','isToBet');
return;
@@ -107,6 +109,7 @@ class ToBetDtService
$res = Bet::toBet($tableInfo,$userInfo,$numberTabInfo,$prevBetInfo,$data,$seat_num,$betTotalAmount,$time,0);
if($res){
Logger::info(Logger::CAT_BET, 'dt_bet_success', ['user_id' => $userInfo['id'], 'table_id' => $tableInfo['id'], 'amount' => $amount]);
$ws->emit('toBet',['status' => true, 'table_id' => $tableInfo['id'], 'bet_amount_msg' => $betTotalAmount, 'money' => ($userInfo['money'] - $amount),'seat_num' => $seat_num, 'msg' => 'to_bet_success']);
if($userInfo['bet_type'] == 2){
$tableManager = app('swoole.table.manager');
@@ -128,6 +131,7 @@ class ToBetDtService
);
$ws->to(SocketSession::HOUSE_NAME)->emit('allBetAmount',['status' => true, 'table_id' => $tableInfo['id'], 'round' => $round]);
}else{
Logger::warn(Logger::CAT_BET, 'dt_bet_db_fail', ['user_id' => $userInfo['id'], 'table_id' => $tableInfo['id'], 'amount' => $amount]);
$ws->emit('toBet',['status' => false, 'table_id' => $tableInfo['id'], 'msg' => 'to_bet_fail']);
}
SocketSession::resetRepeat($fd,'user','isToBet');
+4
View File
@@ -4,6 +4,7 @@
namespace app\services\bet;
use app\models\bet\Bet;
use app\utils\Logger;
use freedom\utils\SocketSession;
/**
@@ -49,6 +50,7 @@ class ToBetNnService
$time = time();
$toBetCheck = ToBetCommonService::toBetCheck($tableInfo,$event,$data);
if ($toBetCheck['status'] == false){
Logger::warn(Logger::CAT_BET, 'nn_bet_fail', ['table_id' => $tableInfo['id'], 'msg' => $toBetCheck['msg']]);
$ws->emit('toBet',['status' => false, 'table_id' => $tableInfo['id'], 'msg' => $toBetCheck['msg']]);
SocketSession::resetRepeat($fd,'user','isToBet');
return;
@@ -181,9 +183,11 @@ class ToBetNnService
$res = Bet::toBet($tableInfo,$userInfo,$numberTabInfo,$prevBetInfo,$data,$seat_num,$betTotalAmount,$time,0);
if($res){
Logger::info(Logger::CAT_BET, 'nn_bet_success', ['user_id' => $userInfo['id'], 'table_id' => $tableInfo['id'], 'amount' => $amount]);
$ws->emit('toBet',['status' => true, 'table_id' => $tableInfo['id'], 'bet_amount_msg' => $betTotalAmount, 'money' => ($userInfo['money'] - $amount),'seat_num' => $seat_num, 'msg' => 'to_bet_success']);
// 待确定是否推送即时彩池,现不推送
}else{
Logger::warn(Logger::CAT_BET, 'nn_bet_db_fail', ['user_id' => $userInfo['id'], 'table_id' => $tableInfo['id'], 'amount' => $amount]);
$ws->emit('toBet',['status' => false, 'table_id' => $tableInfo['id'], 'msg' => 'to_bet_fail']);
}
SocketSession::resetRepeat($fd,'user','isToBet');
@@ -3,6 +3,7 @@
namespace app\services\bet;
use app\models\bet\Bet;
use app\utils\Logger;
use freedom\utils\RouletteUtil;
use freedom\utils\SocketSession;
@@ -36,6 +37,7 @@ class ToBetRouletteService{
$time = time();
$toBetCheck = ToBetCommonService::toBetCheck($tableInfo,$event,$data);
if ($toBetCheck['status'] == false){
Logger::warn(Logger::CAT_BET, 'roulette_bet_fail', ['table_id' => $tableInfo['id'], 'msg' => $toBetCheck['msg']]);
$ws->emit('toBet',['status' => false, 'table_id' => $tableInfo['id'], 'msg' => $toBetCheck['msg']]);
SocketSession::resetRepeat($fd,'user','isToBet');
return;
@@ -61,7 +63,9 @@ class ToBetRouletteService{
'amount_item' => $data
];
$ws->to(SocketSession::HOUSE_NAME)->emit('allBetAmount',['status' => true, 'table_id' => $tableInfo['id'], 'round' => $round]);
Logger::info(Logger::CAT_BET, 'roulette_bet_success', ['user_id' => $userInfo['id'], 'table_id' => $tableInfo['id'], 'amount' => $amount]);
}else{
Logger::warn(Logger::CAT_BET, 'roulette_bet_fail', ['user_id' => $userInfo['id'], 'table_id' => $tableInfo['id']]);
$ws->emit('toBet',['status' => false, 'table_id' => $tableInfo['id'], 'msg' => 'to_bet_fail']);
}
SocketSession::resetRepeat($fd,'user','isToBet');
+4
View File
@@ -4,6 +4,7 @@
namespace app\services\bet;
use app\models\bet\Bet;
use app\utils\Logger;
use freedom\utils\SocketSession;
/**
@@ -50,6 +51,7 @@ class ToBetTcService
$time = time();
$toBetCheck = ToBetCommonService::toBetCheck($tableInfo,$event,$data);
if ($toBetCheck['status'] == false){
Logger::warn(Logger::CAT_BET, 'tc_bet_fail', ['table_id' => $tableInfo['id'], 'msg' => $toBetCheck['msg']]);
$ws->emit('toBet',['status' => false, 'table_id' => $tableInfo['id'], 'msg' => $toBetCheck['msg']]);
SocketSession::resetRepeat($fd,'user','isToBet');
return;
@@ -182,9 +184,11 @@ class ToBetTcService
$res = Bet::toBet($tableInfo,$userInfo,$numberTabInfo,$prevBetInfo,$data,$seat_num,$betTotalAmount,$time,0);
if($res){
Logger::info(Logger::CAT_BET, 'tc_bet_success', ['user_id' => $userInfo['id'], 'table_id' => $tableInfo['id'], 'amount' => $amount]);
$ws->emit('toBet',['status' => true, 'table_id' => $tableInfo['id'], 'bet_amount_msg' => $betTotalAmount, 'money' => ($userInfo['money'] - $amount),'seat_num' => $seat_num, 'msg' => 'to_bet_success']);
// 待确定是否推送即时彩池,现不推送
}else{
Logger::warn(Logger::CAT_BET, 'tc_bet_db_fail', ['user_id' => $userInfo['id'], 'table_id' => $tableInfo['id'], 'amount' => $amount]);
$ws->emit('toBet',['status' => false, 'table_id' => $tableInfo['id'], 'msg' => 'to_bet_fail']);
}
SocketSession::resetRepeat($fd,'user','isToBet');
+4
View File
@@ -4,6 +4,7 @@
namespace app\services\bet;
use app\models\bet\Bet;
use app\utils\Logger;
use freedom\utils\SocketSession;
/**
@@ -36,6 +37,7 @@ class ToBetToningService
$time = time();
$toBetCheck = ToBetCommonService::toBetCheck($tableInfo,$event,$data);
if ($toBetCheck['status'] == false){
Logger::warn(Logger::CAT_BET, 'toning_bet_fail', ['table_id' => $tableInfo['id'], 'msg' => $toBetCheck['msg']]);
$ws->emit('toBet',['status' => false, 'table_id' => $tableInfo['id'], 'msg' => $toBetCheck['msg']]);
SocketSession::resetRepeat($fd,'user','isToBet');
return;
@@ -89,6 +91,7 @@ class ToBetToningService
$res = Bet::toBet($tableInfo,$userInfo,$numberTabInfo,$prevBetInfo,$data,$seat_num,$betTotalAmount,$time,0);
$numberTabAmount = string_to_array($numberTabInfo['toning_amount']);
if($res){
Logger::info(Logger::CAT_BET, 'toning_bet_success', ['user_id' => $userInfo['id'], 'table_id' => $tableInfo['id'], 'amount' => $amount]);
$ws->emit('toBet',['status' => true, 'table_id' => $tableInfo['id'], 'bet_amount_msg' => $betTotalAmount, 'money' => ($userInfo['money'] - $amount),'seat_num' => $seat_num, 'msg' => 'to_bet_success']);
$round = array(
'toning_zero' => isset($numberTabAmount['toning_zero']) ? intval($numberTabAmount['toning_zero'] + $data['toning_zero']) : $data['toning_zero'],
@@ -113,6 +116,7 @@ class ToBetToningService
);
$ws->to(SocketSession::HOUSE_NAME)->emit('allBetAmount',['status' => true, 'table_id' => $tableInfo['id'], 'round' => $round]);
}else{
Logger::warn(Logger::CAT_BET, 'toning_bet_db_fail', ['user_id' => $userInfo['id'], 'table_id' => $tableInfo['id'], 'amount' => $amount]);
$ws->emit('toBet',['status' => false, 'table_id' => $tableInfo['id'], 'msg' => 'to_bet_fail']);
}
SocketSession::resetRepeat($fd,'user','isToBet');
+16 -6
View File
@@ -7,6 +7,7 @@ namespace app\services\connect;
use app\models\process\Boot;
use app\models\process\NumberTab;
use app\models\process\Sumday;
use app\utils\Logger;
/**
* TODO 桌子状态服务
@@ -22,15 +23,24 @@ class InitTableService
*/
public static function initTable(array $tableInfo): array
{
//查询日结
$lastSumday = Sumday::getByTableIdOrderByIdDesc($tableInfo);
if (!$lastSumday) $lastSumday = Sumday::addByTable($tableInfo);
//查询靴
if (!$lastSumday) {
$lastSumday = Sumday::addByTable($tableInfo);
Logger::info(Logger::CAT_GAME, 'init_create_sumday', ['table_id' => $tableInfo['id']]);
}
$lastBoot = Boot::getByTableIdOrderByIdDesc($tableInfo);
if (!$lastBoot) $lastBoot = Boot::addBySumday($lastSumday);
//查询铺
if (!$lastBoot) {
$lastBoot = Boot::addBySumday($lastSumday);
Logger::info(Logger::CAT_GAME, 'init_create_boot', ['table_id' => $tableInfo['id'], 'sumday_id' => $lastSumday['id'] ?? '']);
}
$lastNumberTab = NumberTab::getByBootIdOrderByIdDesc($lastBoot);
if (!$lastNumberTab) $lastNumberTab = NumberTab::addByBoot($lastBoot);
if (!$lastNumberTab) {
$lastNumberTab = NumberTab::addByBoot($lastBoot);
Logger::info(Logger::CAT_GAME, 'init_create_number_tab', ['table_id' => $tableInfo['id'], 'boot_id' => $lastBoot['id'] ?? '']);
}
if (!$lastNumberTab) {
Logger::error(Logger::CAT_GAME, 'init_table_fail', ['table_id' => $tableInfo['id'], 'table_name' => $tableInfo['table_name'] ?? '']);
}
return $lastNumberTab;
}