User request logs are saved by default at log/wok-req.log. The maximum file
size is 3 MB and there is rotation with log/wok-req.log.1, which means it will
spend at most 6 MB of disk space.
The log format is JSON, since the web user interface will provide a log utility
to easily search and filter log results. Sample contents of log/wok-req.log:
{"date": "2016-02-23", "app": "gingerbase",
"req": "DELETE", "user": "lucio",
"time": "15:08:02"} >>> Delete host debug report
'test1'
{"date": "2016-02-23", "app": "gingerbase",
"req": "POST", "user": "lucio", "time":
"15:41:07"} >>> Enable host software repository 'rhel7.2'
{"date": "2016-02-23", "app": "gingerbase",
"req": "POST", "user": "lucio", "time":
"15:42:07"} >>> Disable host software repository 'rhel7.2'
There will be a download function for search results, which will generate a
more log-like text file based on the search results.
Request log results can be searched using the following parameters:
* app: filter by application that received the request (wok, kimchi, etc.)
* user: filter by user that performed the request
* req: filter by request type: POST, DELETE, PUT. GET requests are not logged.
* date: filter by request date in format YYYY-MM-DD
Sample search on user request log using parameters user and app:
curl -u lucio -H "Content-Type: application/json" -H "Accept:
application/json" "http://localhost:8010/logs?app=wok&user=root" -X GET
-d '{}'
Lucio Correia (4):
Add User Request Logger
Log user requests
Implement User Request Logger API
Fix tests
docs/API/logs.md | 21 ++++++++++
src/wok/control/base.py | 80 ++++++++++++++++++++++++++++++++++---
src/wok/control/logs.py | 43 ++++++++++++++++++++
src/wok/model/logs.py | 31 +++++++++++++++
src/wok/reqlogger.py | 103 ++++++++++++++++++++++++++++++++++++++++++++++++
src/wok/server.py | 10 +++++
src/wok/utils.py | 12 ++++++
src/wokd.in | 4 ++
tests/utils.py | 1 +
9 files changed, 299 insertions(+), 6 deletions(-)
create mode 100644 docs/API/logs.md
create mode 100644 src/wok/control/logs.py
create mode 100644 src/wok/model/logs.py
create mode 100644 src/wok/reqlogger.py
--
1.9.1