@regis thanks for the answer and for trying to help.
I have done the following:
- Created a Python project with a
setup.py
file and an EventsHandler.py
class, inside a directory. The structure is:
events_handler/
EventsHandlerpy
setup.py
The setup.py
:
"""Setup for poll XBlock."""
from __future__ import absolute_import
import os
from setuptools import setup
def package_data(pkg, roots):
"""
Generic function to find package_data.
All of the files under each of the `roots` will be declared as package
data for package `pkg`.
"""
data = []
for root in roots:
for dirname, _, files in os.walk(os.path.join(pkg, root)):
for fname in files:
data.append(os.path.relpath(os.path.join(dirname, fname), pkg))
return {pkg: data}
setup(
name='events_handler',
version='0.0.1',
description='An events handler for the project.',
packages=[
'events_handler',
],
install_requires=[
],
entry_points={
'events_handler.v1': [
'events_handler = events_handler:EventsHandler',
]
},
package_data=package_data("events_handler", []),
)
- In the
EventsHandler.py
, I have a class that uses the send
method, as you said:
...
def send(self, event):
"""Send the event to the standard python logger"""
event_str = json.dumps(event, cls=DateTimeJSONEncoder)
# TODO: do something smarter than simply dropping the event on
# the floor.
if self.max_event_size is None or len(event_str) <= self.max_event_size:
self.log("My Events Handler works!");
self.log(event_str)
...
I only added an additional self.log
call, in order to see if it works.
This repository now exists in .local/share/tutor/env/build/openedx/requirements/my-events-handler
directory.
- I have also edited the
.local/share/tutor/env/build/openedx/requirements/private.txt
to include the following:
# Add your additional requirements, such as xblocks, to this file. For
# requirements coming from private repositories, clone the repository to this
# folder and then add your requirement with the `-e` flag. Ex:
#
# git clone git@myserver:myprivaterepo.git
# echo "-e ./myprivaterepo/" >> private.txt-e ./openedx-ensoed-events-handler
-e ./my-events-handler
- I then run
tutor images build openedx
and tutor local start
, but as I can see from the logging file, all the logs are only logged once, just as before (I don’t see the logs from my EventsHandler.py
).
Do you have any idea on what I am doing wrong?
Should I add anything to the EVENT_TRACKING_BACKENDS
settings?
Thanks in advance.