Skip to content

Commit 21f3471

Browse files
committed
feat: add a remote non-finalised log file getter from Tornado
1 parent 5109e00 commit 21f3471

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/DIRAC/WorkloadManagementSystem/Client/PilotLoggingPlugins/FileCacheLoggingPlugin.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,26 @@ def getMeta(self):
104104
return S_OK(self.meta)
105105
return S_ERROR("No Pilot logging directory defined")
106106

107+
def getLogs(self, logfile, vo):
108+
"""
109+
Get the "instant" logs from Tornado log storage area. There are not finalised (incomplete) logs.
110+
111+
:return: Dirac S_OK containing the logs
112+
:rtype: dict
113+
"""
114+
115+
filename = os.path.join(self.meta["LogPath"], vo, logfile)
116+
resultDict = {}
117+
try:
118+
with open(filename) as f:
119+
stdout = f.read()
120+
resultDict["StdOut"] = stdout
121+
except FileNotFoundError as err:
122+
sLog.error(f"Error opening a log file:{filename}", err)
123+
return S_ERROR(repr(err))
124+
125+
return S_OK(resultDict)
126+
107127
def _verifyUUIDPattern(self, logfile):
108128
"""
109129
Verify if the name of the log file matches the required pattern.

src/DIRAC/WorkloadManagementSystem/Service/TornadoPilotLoggingHandler.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ def export_getMetadata(self):
8080
"""
8181
return self.loggingPlugin.getMeta()
8282

83+
def export_getLogs(self, logfile, vo):
84+
"""
85+
Get (not yet finalised) logs from the server.
86+
87+
:return: S_OK containing a metadata dictionary
88+
:rtype: dict
89+
"""
90+
91+
return self.loggingPlugin.getLogs(logfile, vo)
92+
8393
def export_finaliseLogs(self, payload, pilotUUID):
8494
"""
8595
Finalise a log file. Finalised logfile can be copied to a secure location, if a file cache is used.

0 commit comments

Comments
 (0)