Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
docs/API/logs.md | 21 +++++++++++++++++++++
src/wok/control/logs.py | 43 +++++++++++++++++++++++++++++++++++++++++++
src/wok/model/logs.py | 33 +++++++++++++++++++++++++++++++++
3 files changed, 97 insertions(+)
create mode 100644 docs/API/logs.md
create mode 100644 src/wok/control/logs.py
create mode 100644 src/wok/model/logs.py
diff --git a/docs/API/logs.md b/docs/API/logs.md
new file mode 100644
index 0000000..4e836e3
--- /dev/null
+++ b/docs/API/logs.md
@@ -0,0 +1,21 @@
+## REST API Specification for Logs
+
+### Collection: Logs
+
+**URI:** /logs
+
+**Methods:**
+
+* **GET**: Retrieve a list of entries from User Request Log
+ * Parameters:
+ * app: Filter entries by application that received the request.
+ Use "wok" or any plugin installed, like "kimchi".
+ * req: Filter entries by type of request: "DELETE", "POST",
"PUT".
+ "GET" requests are not logged.
+ * user: Filter entries by user that performed the request.
+ * date: Filter entries by date of record in the format "YYYY-MM-DD"
+
+#### Examples
+GET /logs
+[{entry-record1}, {entry-record2}, {entry-record3}, ...]
+
diff --git a/src/wok/control/logs.py b/src/wok/control/logs.py
new file mode 100644
index 0000000..0eb04d7
--- /dev/null
+++ b/src/wok/control/logs.py
@@ -0,0 +1,43 @@
+#
+# Project Wok
+#
+# Copyright IBM Corp, 2016
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+import wok.template
+
+from wok.control.base import SimpleCollection
+from wok.control.utils import get_class_name, model_fn
+from wok.control.utils import UrlSubNode
+
+
+@UrlSubNode("logs")
+class Logs(SimpleCollection):
+ def __init__(self, model):
+ super(Logs, self).__init__(model)
+ self.role_key = 'logs'
+ self.admin_methods = ['GET']
+
+ def get(self, filter_params):
+ res_list = []
+
+ try:
+ get_list = getattr(self.model, model_fn(self, 'get_list'))
+ res_list = get_list(filter_params)
+ except AttributeError:
+ pass
+
+ return wok.template.render(get_class_name(self), res_list)
diff --git a/src/wok/model/logs.py b/src/wok/model/logs.py
new file mode 100644
index 0000000..09d3f47
--- /dev/null
+++ b/src/wok/model/logs.py
@@ -0,0 +1,33 @@
+#
+# Project Wok
+#
+# Copyright IBM Corp, 2016
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+import cherrypy
+
+from wok.reqlogger import RequestParser
+
+
+class LogsModel(object):
+ def __init__(self, **kargs):
+ pass
+
+ def get_list(self, filter_params):
+ if filter_params:
+ return RequestParser().getFilteredRecords(filter_params)
+
+ return RequestParser().getRecords()
--
1.9.1