Commit d54465f0 authored by Rafael Monnerat's avatar Rafael Monnerat

Fix (tail|get)(Event|Access)Log on SlapOS environment

Fix tailEventLog, getEventLog, getAccessLog and added tailAccessLog.
The file log location is got from logging, instead guess a standard.
parent 7c9c2e1f
...@@ -44,8 +44,13 @@ from Products.ERP5Type.Cache import CachingMethod ...@@ -44,8 +44,13 @@ from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5Type import tarfile from Products.ERP5Type import tarfile
from cgi import escape from cgi import escape
import logging
_MARKER = [] _MARKER = []
event_log = logging.getLogger()
access_log = logging.getLogger("access")
class IntrospectionTool(LogMixin, BaseTool): class IntrospectionTool(LogMixin, BaseTool):
""" """
This tool provides both local and remote introspection. This tool provides both local and remote introspection.
...@@ -161,34 +166,18 @@ class IntrospectionTool(LogMixin, BaseTool): ...@@ -161,34 +166,18 @@ class IntrospectionTool(LogMixin, BaseTool):
return '' return ''
security.declareProtected(Permissions.ManagePortal, 'getAccessLog') def __getEventLogPath(self):
def getAccessLog(self, compressed=1, REQUEST=None):
""" """
Get the Access Log. Get the Event Log.
""" """
if REQUEST is not None: return event_log.handlers[0].baseFilename
response = REQUEST.RESPONSE
else:
return "FAILED"
return self._getLocalFile(REQUEST, response,
file_path='log/Z2.log',
compressed=compressed)
security.declareProtected(Permissions.ManagePortal, 'getEventLog') def __getAccessLogPath(self):
def getEventLog(self, compressed=1, REQUEST=None):
""" """
Get the Event Log. Get the Event Log.
""" """
if REQUEST is not None: return access_log.handlers[0].baseFilename
response = REQUEST.RESPONSE
else:
return "FAILED"
return self._getLocalFile(REQUEST, response,
file_path='log/event.log',
compressed=compressed)
def _tailFile(self, file_name, line_number=10): def _tailFile(self, file_name, line_number=10):
""" """
...@@ -232,10 +221,44 @@ class IntrospectionTool(LogMixin, BaseTool): ...@@ -232,10 +221,44 @@ class IntrospectionTool(LogMixin, BaseTool):
""" """
Tail the Event Log. Tail the Event Log.
""" """
return escape(self._tailFile('log/event.log', 50)) return escape(self._tailFile(self.__getEventLogPath(), 50))
security.declareProtected(Permissions.ManagePortal, 'tailAccessLog')
def tailAccessLog(self):
"""
Tail the Event Log.
"""
return escape(self._tailFile(self.__getAccessLogPath(), 50))
security.declareProtected(Permissions.ManagePortal, 'getAccessLog') security.declareProtected(Permissions.ManagePortal, 'getAccessLog')
def getAccessLog(self, compressed=1, REQUEST=None):
"""
Get the Access Log.
"""
if REQUEST is not None:
response = REQUEST.RESPONSE
else:
return "FAILED"
return self._getLocalFile(REQUEST, response,
file_path=self.__getAccessLogPath(),
compressed=compressed)
security.declareProtected(Permissions.ManagePortal, 'getEventLog')
def getEventLog(self, compressed=1, REQUEST=None):
"""
Get the Event Log.
"""
if REQUEST is not None:
response = REQUEST.RESPONSE
else:
return "FAILED"
return self._getLocalFile(REQUEST, response,
file_path=self.__getEventLogPath(),
compressed=compressed)
security.declareProtected(Permissions.ManagePortal, 'getDataFs')
def getDataFs(self, compressed=1, REQUEST=None): def getDataFs(self, compressed=1, REQUEST=None):
""" """
Get the Data.fs. Get the Data.fs.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment