update 20.10.2025
This commit is contained in:
parent
8c11130b5d
commit
a939cd51ef
616 changed files with 84821 additions and 4121 deletions
76
dev/app-bak/Services/SysLog.php
Normal file
76
dev/app-bak/Services/SysLog.php
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Mail\MailSyS;
|
||||
use App\Models\Logger;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
class SysLog
|
||||
{
|
||||
|
||||
|
||||
/* protected $user_id;
|
||||
protected $model;
|
||||
protected $model_id;
|
||||
protected $message;
|
||||
protected $action;
|
||||
protected $channel;
|
||||
protected $level;*/
|
||||
|
||||
protected $log;
|
||||
|
||||
public $levelTypes = [
|
||||
1 => 'debug',
|
||||
2 => 'info',
|
||||
3 => 'notice',
|
||||
4 => 'warning',
|
||||
5 => 'error',
|
||||
6 => 'critical',
|
||||
7 => 'alert',
|
||||
];
|
||||
|
||||
function __construct($action = null, $channel = 'default', $level = 1)
|
||||
{
|
||||
$this->log = new Logger();
|
||||
$this->log->action = $action;
|
||||
$this->log->channel = $channel;
|
||||
$this->log->level = $level;
|
||||
}
|
||||
|
||||
public static function action($action = null, $channel = 'default', $level = 1)
|
||||
{
|
||||
//Return new instance of this model
|
||||
return new self($action, $channel, $level);
|
||||
}
|
||||
|
||||
public function setModel($id, $model){
|
||||
$this->log->model_id = $id;
|
||||
$this->log->model = $model;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUserId($user_id){
|
||||
$this->log->user_id = $user_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMessage($message){
|
||||
$this->log->message = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function save(){
|
||||
$this->log->save();
|
||||
//send Mail
|
||||
if($this->log->level >= 3){
|
||||
$mail = config('app.info_test_mail');
|
||||
Mail::to($mail)->send(new MailSyS($this->log, 'log'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue