login browse log
This commit is contained in:
parent
bbc831b4b5
commit
e5d73a372e
@ -5,6 +5,7 @@ use think\Model;
|
|||||||
use think\model\concern\SoftDelete;
|
use think\model\concern\SoftDelete;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
use think\facade\Session;
|
use think\facade\Session;
|
||||||
|
use think\facade\Log;
|
||||||
use taoler\com\Api;
|
use taoler\com\Api;
|
||||||
|
|
||||||
class User extends Model
|
class User extends Model
|
||||||
@ -70,6 +71,7 @@ class User extends Model
|
|||||||
'last_login_time' => time()
|
'last_login_time' => time()
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
Log::channel('login')->info('login:{user} {ip}:{city}',['user'=>$user['name'],'ip'=>$ip,'city'=>$city]);
|
||||||
|
|
||||||
//查询结果1表示有用户,用户名密码正确
|
//查询结果1表示有用户,用户名密码正确
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
\app\middleware\Install::class,
|
\app\middleware\Install::class,
|
||||||
|
\app\middleware\Browse::class,
|
||||||
//app\middleware\LoginCheck::class,
|
//app\middleware\LoginCheck::class,
|
||||||
//app\middleware\CheckRegister::class,
|
//app\middleware\CheckRegister::class,
|
||||||
//'logedcheck' => \app\middleware\logedCheck::class,
|
//'logedcheck' => \app\middleware\logedCheck::class,
|
||||||
|
17
app/middleware/Browse.php
Normal file
17
app/middleware/Browse.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\middleware;
|
||||||
|
use think\facade\Request;
|
||||||
|
use think\facade\Log;
|
||||||
|
|
||||||
|
class Browse
|
||||||
|
{
|
||||||
|
public function handle($request, \Closure $next)
|
||||||
|
{
|
||||||
|
$agent = $_SERVER['HTTP_USER_AGENT'];
|
||||||
|
$ip = $_SERVER['REMOTE_ADDR'];
|
||||||
|
$url = Request::url(true);
|
||||||
|
Log::channel('browse')->info('browse:{agent} {ip} {url}',['agent'=>$agent,'url'=>$url,'ip'=>$ip]);
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
@ -40,6 +40,38 @@ return [
|
|||||||
'realtime_write' => false,
|
'realtime_write' => false,
|
||||||
],
|
],
|
||||||
// 其它日志通道配置
|
// 其它日志通道配置
|
||||||
|
'login' => [
|
||||||
|
// 日志记录方式
|
||||||
|
'type' => 'File',
|
||||||
|
// 日志保存目录
|
||||||
|
'path' => '../runtime/log/login/',
|
||||||
|
// 单文件日志写入
|
||||||
|
'single' => false,
|
||||||
|
// 最大日志文件数量
|
||||||
|
'max_files' => 0,
|
||||||
|
// 日志处理
|
||||||
|
'processor' => null,
|
||||||
|
// 日志输出格式化
|
||||||
|
'format' => '[%s][%s] %s',
|
||||||
|
// 是否实时写入
|
||||||
|
'realtime_write' => true,
|
||||||
|
],
|
||||||
|
'browse' => [
|
||||||
|
// 日志记录方式
|
||||||
|
'type' => 'File',
|
||||||
|
// 日志保存目录
|
||||||
|
'path' => '../runtime/log/browse/',
|
||||||
|
// 单文件日志写入
|
||||||
|
'single' => false,
|
||||||
|
// 最大日志文件数量
|
||||||
|
'max_files' => 0,
|
||||||
|
// 日志处理
|
||||||
|
'processor' => null,
|
||||||
|
// 日志输出格式化
|
||||||
|
'format' => '[%s][%s] %s',
|
||||||
|
// 是否实时写入
|
||||||
|
'realtime_write' => true,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user