diff --git a/src/DIRAC/WorkloadManagementSystem/Client/PilotLoggingPlugins/FileCacheLoggingPlugin.py b/src/DIRAC/WorkloadManagementSystem/Client/PilotLoggingPlugins/FileCacheLoggingPlugin.py index 32ca1eb65cb..91ea6d89a3a 100644 --- a/src/DIRAC/WorkloadManagementSystem/Client/PilotLoggingPlugins/FileCacheLoggingPlugin.py +++ b/src/DIRAC/WorkloadManagementSystem/Client/PilotLoggingPlugins/FileCacheLoggingPlugin.py @@ -104,6 +104,26 @@ def getMeta(self): return S_OK(self.meta) return S_ERROR("No Pilot logging directory defined") + def getLogs(self, logfile, vo): + """ + Get the "instant" logs from Tornado log storage area. There are not finalised (incomplete) logs. + + :return: Dirac S_OK containing the logs + :rtype: dict + """ + + filename = os.path.join(self.meta["LogPath"], vo, logfile) + resultDict = {} + try: + with open(filename) as f: + stdout = f.read() + resultDict["StdOut"] = stdout + except FileNotFoundError as err: + sLog.error(f"Error opening a log file:{filename}", err) + return S_ERROR(repr(err)) + + return S_OK(resultDict) + def _verifyUUIDPattern(self, logfile): """ Verify if the name of the log file matches the required pattern. diff --git a/src/DIRAC/WorkloadManagementSystem/Service/TornadoPilotLoggingHandler.py b/src/DIRAC/WorkloadManagementSystem/Service/TornadoPilotLoggingHandler.py index cd98938096f..512a136ca7c 100644 --- a/src/DIRAC/WorkloadManagementSystem/Service/TornadoPilotLoggingHandler.py +++ b/src/DIRAC/WorkloadManagementSystem/Service/TornadoPilotLoggingHandler.py @@ -80,6 +80,16 @@ def export_getMetadata(self): """ return self.loggingPlugin.getMeta() + def export_getLogs(self, logfile, vo): + """ + Get (not yet finalised) logs from the server. + + :return: S_OK containing a metadata dictionary + :rtype: dict + """ + + return self.loggingPlugin.getLogs(logfile, vo) + def export_finaliseLogs(self, payload, pilotUUID): """ Finalise a log file. Finalised logfile can be copied to a secure location, if a file cache is used.