Commit 262bfe07 authored by Nathalie Rousse's avatar Nathalie Rousse
Browse files

Adding activities log file

parent fc4ed340
......@@ -103,6 +103,12 @@ LOGGING_FILE = os.path.join(factory_path, 'log', 'erecord.log' )
Value None for no file destination for logging information
"""
LOG_ACT_ACTIVE = True
"""To (des)activate recording activities events into LOG_ACT_FILE"""
LOG_ACT_FILE = os.path.join(factory_path, 'log', 'erecord_act.log' )
"""File where recorded activities events"""
# databases (only one)
DB_NAME_DEFAULT = 'default'
......
......@@ -278,6 +278,21 @@ class ActivityViewMixin(LimitedAccessViewMixin, RenderViewMixin,
options['report'] = report_option
return options
def to_log(url_txt, data) :
"""Records activity event into activity log file"""
import datetime
from erecord_cmn.configs.config import LOG_ACT_FILE
from erecord_cmn.configs.config import LOG_ACT_ACTIVE
if LOG_ACT_ACTIVE :
text = str(datetime.datetime.now())
text += " -R- " + url_txt
text += " -D- " + str(data) + "\n"
f = open(LOG_ACT_FILE, "a")
f.write(text)
f.close()
def init_activity(self, LOGGER, data):
"""initial build
......
......@@ -255,6 +255,7 @@ class ExperimentViewMixin(DataFolderViewMixin, ReportViewMixin):
"""action done for a POST request about experiment of a vpz"""
try :
self.to_log("POST vpz/experiment", data)
res = self.init_activity(LOGGER=LOGGER, data=data)
except :
raise
......@@ -302,6 +303,7 @@ class ExperimentViewMixin(DataFolderViewMixin, ReportViewMixin):
"""
try :
self.to_log("GET vpz/experiment", data)
res = self.init_activity(LOGGER=LOGGER, data=data)
except :
raise
......
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