12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace app\admin\service;
- use library\tools\Node;
- use think\Db;
- class Log
- {
-
- public static function write($action = '行为', $content = "内容描述")
- {
- $data = [
- 'node' => Node::current(),
- 'geoip' => PHP_SAPI === 'cli' ? '127.0.0.1' : request()->ip(),
- 'action' => $action,
- 'content' => $content,
- 'username' => PHP_SAPI === 'cli' ? 'cli' : session('user.username'),
- ];
- return Db::name('SystemLog')->insert($data) !== false;
- }
-
- public static function clear()
- {
- return Db::name('SystemLog')->where('1=1')->delete() !== false;
- }
- }
|