feat: move miniapp server project
This commit is contained in:
parent
4a940f28ba
commit
96d9063b13
178 changed files with 9699 additions and 5044 deletions
51
app/service/BaseService.php
Normal file
51
app/service/BaseService.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace app\service;
|
||||
|
||||
use think\Service;
|
||||
use think\facade\Log;
|
||||
use think\exception\ErrorException;
|
||||
|
||||
class BaseService extends Service
|
||||
{
|
||||
private $className = '';
|
||||
public function __construct($className)
|
||||
{
|
||||
$this->className = $className;
|
||||
}
|
||||
protected function log_notice($any, $msg = '', $tag = 'log_notice')
|
||||
{
|
||||
if ($any instanceof ErrorException || $any instanceof Exception) {
|
||||
$str = c_formate_exception($any);
|
||||
} else {
|
||||
$str = json_encode($any, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
Log::write('[' . $this->className . ']' . '[' . $tag . ']' . '[' . $msg . ']' . '[' . $str . ']', 'NOTICE');
|
||||
}
|
||||
protected function log_warn($any, $msg = '', $tag = 'log_warn')
|
||||
{
|
||||
if ($any instanceof ErrorException || $any instanceof Exception) {
|
||||
$str = c_formate_exception($any);
|
||||
} else {
|
||||
$str = json_encode($any, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
Log::write('[' . $this->className . ']' . '[' . $tag . ']' . '[' . $msg . ']' . '[' . json_encode($any, JSON_UNESCAPED_UNICODE) . ']', 'WARN');
|
||||
}
|
||||
protected function log_error($any, $msg = '', $tag = 'log_error')
|
||||
{
|
||||
if ($any instanceof ErrorException || $any instanceof Exception) {
|
||||
$str = c_formate_exception($any);
|
||||
} else {
|
||||
$str = json_encode($any, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
Log::write('[' . $this->className . ']' . '[' . $tag . ']' . '[' . $msg . ']' . '[' . json_encode($any, JSON_UNESCAPED_UNICODE) . ']', 'ERROR');
|
||||
}
|
||||
protected function alarm($type = '', $content = '')
|
||||
{
|
||||
D('alarm')->insert([
|
||||
'type' => $type,
|
||||
'content' => $content,
|
||||
'create_time' => c_now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue