Skip to content

Commit

Permalink
cat-log: view retrieved remote logs locally.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoliver committed Apr 17, 2018
1 parent f33703c commit 77b120a
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions bin/cylc-cat-log
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@

"""cylc [info] cat-log|log [OPTIONS] ARGS
Print, edit, or tail-follow content, or print path or list directory, of local
or remote task job logs and suite server logs. Batch-system-specific job cat or
tail commands are used if defined in global config.
Cat (print), edit, or tail-follow content, or print path or list directory, of
local or remote task job logs and suite server logs. Batch-system view commands
(e.g. 'qcat') are used if defined in global config and the job is running.
For standard log types use the short-cut option argument or full filename (e.g.
for job stdout "-f o" or "-f job.out" will do).
To list the local job log directory of a remote task, choose "-m l" (directory
list mode) and a local file, e.g. "-f a" (job-activity.log).
Custom job logs are assumed to reside on the job host. These will be available
to view from the GUI if listed in 'extra log files' in the suite definition.
Here the file name must be given (but it can be discovered with list-dir mode).
If remote job logs are retrieved to the suite host on completion (global config
'[JOB-HOST]retrieve job logs = True') and the job is not currently running, the
local (retrieved) log will be accessed unless '-o/--force-remote' is used.
Custom job logs (written to $CYLC_TASK_LOG_ROOT on the job host) are available
from the GUI if listed in 'extra log files' in the suite definition. The file
name must be given here, but can be discovered with '--mode=l' (list-dir).
The correct cycle point format of the suite must be for task job logs.
Expand Down Expand Up @@ -195,6 +199,12 @@ def get_option_parser():
"next oldest, etc.",
metavar="INT", action="store", dest="rotation_num")

parser.add_option(
"-o", "--force-remote",
help="View remote logs remotely even if they have been retrieved"
" to the suite host (default False).",
action="store_true", default=False, dest="force_remote")

parser.add_option(
"-s", "--submit-number", "-t", "--try-number",
help="Job submit number (default=%s, i.e. latest)." % NN,
Expand Down Expand Up @@ -351,8 +361,8 @@ def main():
user, host = split_user_at_host(user_at_host)
batchview_cmd = None
if live_job_id is not None:
# Get special batch system log viewer command (e.g. qcat) if one
# exists, the log is out or err, and the job is live.
# Job is currently running. Get special batch system log view
# command (e.g. qcat) if one exists, and the log is out or err.
conf_key = None
if options.filename == JOB_LOG_OUT:
if options.mode == 'c':
Expand All @@ -374,8 +384,12 @@ def main():
if batchview_cmd_tmpl is not None:
batchview_cmd = batchview_cmd_tmpl % {
"job_id": str(live_job_id)}
pout = None
if is_remote(user, host) and (options.filename not in JOB_LOGS_LOCAL):

log_is_remote = (is_remote(user, host)
and (options.filename not in JOB_LOGS_LOCAL))
log_is_retrieved = (glbl_cfg().get_host_item('retrieve job logs', host)
and live_job_id is None)
if log_is_remote and (not log_is_retrieved or options.force_remote):
logpath = os.path.normpath(os.path.join(
glbl_cfg().get_derived_host_item(
suite_name, "suite job log directory", host, user),
Expand Down

0 comments on commit 77b120a

Please sign in to comment.