Commit fcd26be0 authored by Jérome Perrin's avatar Jérome Perrin

CMFActivity,syncml: stop using a dedicated log file

$INSTANCE_HOME/log only exists in runUnitTest instances, this code had
no effect in slapos instances.

It is a future problem because it depends on the Signals module (part
of ZServer package) and we are removing this dependency in the python 3
port.

For the SynchronizationTool, it was even more problematic because it
can cause the component not to loed, with an error like:

    ImportError: erp5.component.tool.SynchronizationTool: cannot load Component SynchronizationTool (signal only works in main thread)
parent 038bfcc5
......@@ -25,8 +25,7 @@
#
##############################################################################
from os import path
from logging import getLogger, Formatter
from logging import getLogger
from AccessControl import ClassSecurityInfo
......@@ -43,30 +42,7 @@ from Products.ERP5.ERP5Site import getSite
synchronous_engine = SyncMLSynchronousEngine()
asynchronous_engine = SyncMLAsynchronousEngine()
# Logging channel definitions
# Main logging channel
syncml_logger = getLogger('ERP5SyncML')
# Direct logging to "[instancehome]/log/ERP5SyncML.log", if this
# directory exists. Otherwise, it will end up in root logging
# facility (ie, event.log).
from App.config import getConfiguration
instancehome = getConfiguration().instancehome
if instancehome is not None:
log_directory = path.join(instancehome, 'log')
if path.isdir(log_directory):
from Signals import Signals
from ZConfig.components.logger.loghandler import FileHandler
log_file_handler = FileHandler(path.join(log_directory,
'ERP5SyncML.log'))
# Default zope log format string borrowed from
# ZConfig/components/logger/factory.xml, but without the extra "------"
# line separating entries.
log_file_handler.setFormatter(Formatter(
"%(asctime)s %(levelname)s %(name)s %(message)s",
"%Y-%m-%dT%H:%M:%S"))
Signals.registerZopeSignals([log_file_handler])
syncml_logger.addHandler(log_file_handler)
syncml_logger.propagate = 0
def checkAlertCommand(syncml_request):
......
......@@ -98,24 +98,6 @@ activity_logger = logging.getLogger('CMFActivity')
activity_tracking_logger = logging.getLogger('Tracking')
activity_timing_logger = logging.getLogger('CMFActivity.TimingLog')
# Direct logging to "[instancehome]/log/CMFActivity.log", if this directory exists.
# Otherwise, it will end up in root logging facility (ie, event.log).
from App.config import getConfiguration
import os
instancehome = getConfiguration().instancehome
if instancehome is not None:
log_directory = os.path.join(instancehome, 'log')
if os.path.isdir(log_directory):
from Signals import Signals
from ZConfig.components.logger.loghandler import FileHandler
log_file_handler = FileHandler(os.path.join(log_directory, 'CMFActivity.log'))
# Default zope log format string borrowed from
# ZConfig/components/logger/factory.xml, but without the extra "------"
# line separating entries.
log_file_handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)s %(name)s %(message)s", "%Y-%m-%dT%H:%M:%S"))
Signals.registerZopeSignals([log_file_handler])
activity_logger.addHandler(log_file_handler)
activity_logger.propagate = 0
def activity_timing_method(method, args, kw):
begin = time()
......
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