Repository: dmwm/wmcore
Issue: Use correct logger object for LogDB from the cherrypy threads

Looking at the StatusChangeTasks ReqMgr2 thread, apparently it's having LogDB failures which do not get properly reported. E.g.:
```
2019-03-20 00:04:57,626:INFO:StatusChangeTasks:Deleting vlimant_ACDC0_task_TAU-RunIIAutumn18DRPremix-00082__v1_T_190205_113611_3458 from LogDB WMStats...
2019-03-20 00:04:57,884:ERROR:StatusChangeTasks:Fail to update vlimant_ACDC0_task_TAU-RunIIAutumn18DRPremix-00082__v1_T_190205_113611_3458: 
2019-03-20 00:04:57,894:INFO:StatusChangeTasks:Total announced-archived: 0
```

where the error doesn't get reported. Apparently we're not using the same logger and the error message simply goes to another dimension.

Changed files:
src/python/WMCore/WMStats/CherryPyThreads/LogDBTasks.py, src/python/WMCore/ReqMgr/CherryPyThreads/StatusChangeTasks.py

diff --git a/src/python/WMCore/ReqMgr/CherryPyThreads/StatusChangeTasks.py b/src/python/WMCore/ReqMgr/CherryPyThreads/StatusChangeTasks.py
index 21287bfba..9a491bfbf 100644
--- a/src/python/WMCore/ReqMgr/CherryPyThreads/StatusChangeTasks.py
+++ b/src/python/WMCore/ReqMgr/CherryPyThreads/StatusChangeTasks.py
@@ -6,7 +6,6 @@ from __future__ import (division, print_function)
 import time
 from WMCore.REST.CherryPyPeriodicTask import CherryPyPeriodicTask
 from WMCore.ReqMgr.DataStructs.RequestStatus import AUTO_TRANSITION
-from WMCore.Services.LogDB.LogDB import LogDB
 from WMCore.Services.WorkQueue.WorkQueue import WorkQueue
 from WMCore.Services.ReqMgr.ReqMgr import ReqMgr
 from WMCore.Services.WMStatsServer.WMStatsServer import WMStatsServer
@@ -127,7 +126,6 @@ class StatusChangeTasks(CherryPyPeriodicTask):
         reqmgrSvc = ReqMgr(config.reqmgr2_url, logger=self.logger)
         gqService = WorkQueue(config.workqueue_url)
         wmstatsSvc = WMStatsServer(config.wmstats_url, logger=self.logger)
-        logdb = LogDB(config.central_logdb_url, config.log_reporter)
 
         self.logger.info("Getting GQ data for status check")
         wfStatusDict = gqService.getWorkflowStatusFromWQE()
@@ -135,7 +133,7 @@ class StatusChangeTasks(CherryPyPeriodicTask):
         self.logger.info("Advancing status")
         moveForwardStatus(reqmgrSvc, wfStatusDict, self.logger)
         moveToCompletedForNoWQJobs(reqmgrSvc, wfStatusDict, self.logger)
-        moveToArchived(wmstatsSvc, reqmgrSvc, logdb, config.archiveDelayHours, self.logger)
+        moveToArchived(wmstatsSvc, reqmgrSvc, self.logDB, config.archiveDelayHours, self.logger)
 
         self.logger.info("Done advancing status")
 
diff --git a/src/python/WMCore/WMStats/CherryPyThreads/LogDBTasks.py b/src/python/WMCore/WMStats/CherryPyThreads/LogDBTasks.py
index 2244eb9d5..3d74d55c2 100644
--- a/src/python/WMCore/WMStats/CherryPyThreads/LogDBTasks.py
+++ b/src/python/WMCore/WMStats/CherryPyThreads/LogDBTasks.py
@@ -6,13 +6,11 @@ Created on Aug 13, 2014
 from __future__ import (division, print_function)
 
 from WMCore.REST.CherryPyPeriodicTask import CherryPyPeriodicTask
-from WMCore.Services.LogDB.LogDB import LogDB
 
 class LogDBTasks(CherryPyPeriodicTask):
 
     def __init__(self, rest, config):
         super(LogDBTasks, self).__init__(config)
-        self.logdb = LogDB(config.central_logdb_url, config.log_reporter)
 
     def setConcurrentTasks(self, config):
         """
@@ -25,7 +23,7 @@ class LogDBTasks(CherryPyPeriodicTask):
         gather active data statistics
         """
         self.logger.info("Cleaning documents from LogDB WMStats")
-        docs = self.logdb.cleanup(config.keepDocsAge)
+        docs = self.logDB.cleanup(config.keepDocsAge)
         self.logger.info("Deleted %d old documents", len(docs))
 
         return