diff --git a/api/.env.example b/api/.env.example index 4f5475e..200b03e 100644 --- a/api/.env.example +++ b/api/.env.example @@ -49,12 +49,12 @@ SQLITE_DATABASE = "base_path() . '/database.sqlite'" SQLITE_PREFIX = # mongolog: mongodb记录日志 -MONGOLOG_URL = mongodb://127.0.0.1:27019 +MONGOLOG_URL = mongodb://root:password@127.0.0.1:27019 MONGOLOG_HOST = 127.0.0.1 MONGOLOG_PORT = 27019 MONGOLOG_DATABASE = log -MONGOLOG_USERNAME = -MONGOLOG_PASSWORD = +MONGOLOG_USERNAME = root +MONGOLOG_PASSWORD = password # log LOG_MAX_FIlES = 30 diff --git a/api/app/controller/TestController.php b/api/app/controller/TestController.php index 14e281a..e03a654 100644 --- a/api/app/controller/TestController.php +++ b/api/app/controller/TestController.php @@ -13,13 +13,13 @@ class TestController public function index(Request $request) { $res = Container::make(Res::class); - // Log::channel('default')->info(__CLASS__ . DIRECTORY_SEPARATOR . __FUNCTION__, $_SERVER); - $logs = Db::connection('mongolog')->collection('request')->get(); - // foreach ($logs as $log) { - // $log->delete(); - // } - // $logs->delete(); - $res->setData($logs); + Log::channel('default')->info(__CLASS__ . DIRECTORY_SEPARATOR . __FUNCTION__, $request->all()); + $requestLogs = Db::connection('mongolog')->collection('request')->get(); + $defaultLogs = Db::connection('mongolog')->collection('default')->get(); + $res->setData([ + 'request' => $requestLogs, + 'default' => $defaultLogs, + ]); return json($res); } diff --git a/api/app/middleware/RequestLog.php b/api/app/middleware/RequestLog.php index 784edfb..ad11497 100644 --- a/api/app/middleware/RequestLog.php +++ b/api/app/middleware/RequestLog.php @@ -24,7 +24,7 @@ class RequestLog implements MiddlewareInterface * @var array */ protected $actionWhiteList = [ - 'app\controller\testcontroller\index', // oss里的download不校验 + 'app\controller\testcontroller\index', ]; public function process(Request $request, callable $next) : Response diff --git a/api/composer.json b/api/composer.json index 0f5e342..6e48b73 100644 --- a/api/composer.json +++ b/api/composer.json @@ -26,7 +26,7 @@ "require": { "php": ">=7.2", "workerman/webman-framework": "^1.5.0", - "monolog/monolog": "^3.0", + "monolog/monolog": "^3.5", "vlucas/phpdotenv": "^5.5", "illuminate/database": "^10.0", "illuminate/pagination": "^10.0", diff --git a/api/composer.lock b/api/composer.lock index 11e7983..c5587e6 100644 --- a/api/composer.lock +++ b/api/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b60184ef23f8e71843aa7695eed31518", + "content-hash": "39ff7b274d51d63c430e0f1f75ef26f0", "packages": [ { "name": "brick/math", diff --git a/docker-compose.yml b/docker-compose.yml index b035a96..b192bda 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,21 @@ version: "3.1" services: + + log: + image: mongo:7.0 + container_name: webman-jsonrpc-log + restart: always + environment: + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: password + MONGO_INITDB_DATABASE: log + volumes: + - ./log/db:/data/db + - ./log/mongod.conf:/etc/mongod.conf + network_mode: host + command: ['mongod', '--config', '/etc/mongod.conf'] + api: image: wandoubaba517/workerman:8.1 container_name: webman-jsonrpc-api @@ -14,13 +29,3 @@ services: depends_on: - log command: ['php', 'start.php', 'start'] - - log: - image: mongo:6.0 - container_name: webman-jsonrpc-log - restart: always - volumes: - - ./log/db:/data/db - - ./log/mongod.conf:/etc/mongod.conf - network_mode: host - command: ['mongod', '--config', '/etc/mongod.conf']