Skip to content

Commit

Permalink
feat: add a remote non-finalised log file getter from Tornado
Browse files Browse the repository at this point in the history
  • Loading branch information
martynia committed Sep 12, 2023
1 parent 5109e00 commit 21f3471
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 21f3471

Please sign in to comment.