Commit 4fb2b99e authored by cuiweifeng's avatar cuiweifeng

update: 报警邮件发送自定义

parent 866e88e9
...@@ -24,6 +24,7 @@ use Api\PhpUtils\Log\FileLog; ...@@ -24,6 +24,7 @@ use Api\PhpUtils\Log\FileLog;
* $options参数可选项: * $options参数可选项:
* - $options['max_execution_time'] = 10; // 单位毫秒 * - $options['max_execution_time'] = 10; // 单位毫秒
* - $options['rowCount'] = true; // 返回insert后的影响行数 * - $options['rowCount'] = true; // 返回insert后的影响行数
* - $options['alertMail'] = true; // SQL执行出错是否发送报警邮件标识,默认发送
* @see https://medoo.in (英文网站) * @see https://medoo.in (英文网站)
* @see https://medoo.lvtao.net (中文网站) * @see https://medoo.lvtao.net (中文网站)
...@@ -37,7 +38,7 @@ use Api\PhpUtils\Log\FileLog; ...@@ -37,7 +38,7 @@ use Api\PhpUtils\Log\FileLog;
* @method static MysqlBase select($columns, $where, $options) * @method static MysqlBase select($columns, $where, $options)
* @method static MysqlBase selectMaster($columns, $where, $options) * @method static MysqlBase selectMaster($columns, $where, $options)
* @method static MysqlBase selectForUpdate($columns, $where, $options) * @method static MysqlBase selectForUpdate($columns, $where, $options)
* * @method static MysqlBase selectForUpdateSkipLocked($columns, $where, $options) * @method static MysqlBase selectForUpdateSkipLocked($columns, $where, $options)
* @method static MysqlBase getMaster($columns, $where, $options) * @method static MysqlBase getMaster($columns, $where, $options)
* @method static MysqlBase get($columns, $where, $options) * @method static MysqlBase get($columns, $where, $options)
* @method static MysqlBase count($columns, $where) * @method static MysqlBase count($columns, $where)
...@@ -329,7 +330,15 @@ abstract class MysqlBase ...@@ -329,7 +330,15 @@ abstract class MysqlBase
return true; return true;
} }
FileLog::error("mysql error catch:" . $method . "-" . json_encode($arguments) . '-' . print_r([$sqlState, $errorCode, $errorMessage], 1)); if (in_array(strtolower($method), ['insert']) && isset($arguments[2]['alertMail']) && $arguments[2]['alertMail'] === false) {
FileLog::info("mysql info catch:" . $method . "-" . json_encode($arguments) . '-' . print_r([$sqlState, $errorCode, $errorMessage], 1));
}
elseif (in_array(strtolower($method), ['select', 'selectmaster', 'selectforupdate', 'get', 'getmaster']) && isset($arguments[3]['alertMail']) && $arguments[3]['alertMail'] === false) {
FileLog::info("mysql info catch:" . $method . "-" . json_encode($arguments) . '-' . print_r([$sqlState, $errorCode, $errorMessage], 1));
}
else {
FileLog::error("mysql error catch:" . $method . "-" . json_encode($arguments) . '-' . print_r([$sqlState, $errorCode, $errorMessage], 1));
}
//throw Exception //throw Exception
// $msg = "mysql error catch:" . $method . "-" . json_encode($arguments) . '-' . json_encode([$sqlState, $errorCode, $errorMessage]); // $msg = "mysql error catch:" . $method . "-" . json_encode($arguments) . '-' . json_encode([$sqlState, $errorCode, $errorMessage]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment