X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=activity%2F__init__.py;h=62fbc9e872b173b212cef15aad182a4436ca6fed;hb=92620bf17c60377b7d156a6edf2c6a3077dd2745;hp=e8eb5c3f0b097ab59dd2b2742138ddba61ca956c;hpb=8e18c9ff4a961c70f897ca3915959d2fa3f7fb38;p=unfold.git diff --git a/activity/__init__.py b/activity/__init__.py index e8eb5c3f..62fbc9e8 100644 --- a/activity/__init__.py +++ b/activity/__init__.py @@ -6,8 +6,6 @@ # The secret is a 64 chars string that is used to sign the request # The generated signature is a SHA256 hes digest -from __future__ import print_function - import urllib, urllib2 import threading import hmac @@ -16,6 +14,8 @@ import base64 import time import datetime from myslice.configengine import ConfigEngine +from myslice.settings import logger + config = ConfigEngine() if config.activity and config.activity.apikey : @@ -39,10 +39,10 @@ else : def logWrite(request, action, message, objects = None): if not apikey : - print("===============>> activity: no apikey") + logger.info("===============>> activity: no apikey") return if not secret : - print("===============>> activity: no secret") + logger.info("===============>> activity: no secret") return timestamp = time.mktime(datetime.datetime.today().timetuple()) @@ -71,12 +71,11 @@ def logWrite(request, action, message, objects = None): try : result = urllib2.urlopen(server, urllib.urlencode(log)) - print("===============>> activity: %s <%s> %s" % (action, request.user,message)) + logger.info("===============>> activity: {} <{}> {}".format(action, request.user,message)) content = result.read() except urllib2.URLError as e: - print("===============>> activity: connection to " + server + " impossible, could not log action") - print(e.strerror) - print("") + logger.error("===============>> activity: connection to {} impossible, could not log action".format(server)) + logger.error(e.strerror) def log(request, action, message, objects = None): # Create a new thread in Daemon mode to send the log entry