1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements. See the NOTICE file distributed with
3 # this work for additional information regarding copyright ownership.
4 # The ASF licenses this file to You under the Apache License, Version 2.0
5 # (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 CLI ``logs`` sub-commands.
20 from .. import execution_logging
21 from ..logger import ModelLogIterator
22 from ..core import aria
25 @aria.group(name='logs')
26 @aria.options.verbose()
29 Manage logs of workflow executions
34 @logs.command(name='list',
35 short_help='List logs for an execution')
36 @aria.argument('execution-id')
37 @aria.options.verbose()
38 @aria.options.mark_pattern()
39 @aria.pass_model_storage
41 def list(execution_id, mark_pattern, model_storage, logger):
43 List logs for an execution
45 EXECUTION_ID is the unique ID of the execution.
47 logger.info('Listing logs for execution id {0}'.format(execution_id))
48 log_iterator = ModelLogIterator(model_storage, execution_id)
50 any_logs = execution_logging.log_list(log_iterator, mark_pattern=mark_pattern)
53 logger.info('\tNo logs')
56 @logs.command(name='delete',
57 short_help='Delete logs of an execution')
58 @aria.argument('execution-id')
59 @aria.options.verbose()
60 @aria.pass_model_storage
62 def delete(execution_id, model_storage, logger):
64 Delete logs of an execution
66 EXECUTION_ID is the unique ID of the execution.
68 logger.info('Deleting logs for execution id {0}'.format(execution_id))
69 logs_list = model_storage.log.list(filters=dict(execution_fk=execution_id))
71 model_storage.log.delete(log)
72 logger.info('Deleted logs for execution id {0}'.format(execution_id))