Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-106-Create-sqla-logging-handler 7cb6fba53 -> e4f086643
minor fixes Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/c290a16b Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/c290a16b Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/c290a16b Branch: refs/heads/ARIA-106-Create-sqla-logging-handler Commit: c290a16b836b0b7059bb24303ffb1b3b10e10788 Parents: 7cb6fba Author: mxmrlv <mxm...@gmail.com> Authored: Tue Feb 21 18:34:04 2017 +0200 Committer: mxmrlv <mxm...@gmail.com> Committed: Tue Feb 21 18:34:04 2017 +0200 ---------------------------------------------------------------------- aria/logger.py | 3 +-- aria/orchestrator/context/common.py | 6 ++++-- aria/orchestrator/context/operation.py | 4 ++-- aria/orchestrator/context/workflow.py | 4 ---- aria/orchestrator/workflows/core/task.py | 8 -------- aria/orchestrator/workflows/events_logging.py | 7 ++++--- aria/orchestrator/workflows/executor/thread.py | 2 +- aria/storage/modeling/orchestrator_elements.py | 4 +--- 8 files changed, 13 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c290a16b/aria/logger.py ---------------------------------------------------------------------- diff --git a/aria/logger.py b/aria/logger.py index ae6d4a6..92f3109 100644 --- a/aria/logger.py +++ b/aria/logger.py @@ -159,8 +159,7 @@ class _SQLAlchemyHandler(logging.Handler): created_at = datetime.strptime(logging.Formatter('%(asctime)s').formatTime(record), '%Y-%m-%d %H:%M:%S,%f') log = self._cls( - prefix=record.prefix, - logger=record.name, + actor=record.prefix, level=record.levelname, msg=record.msg, created_at=created_at, http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c290a16b/aria/orchestrator/context/common.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/context/common.py b/aria/orchestrator/context/common.py index b908965..f4d5716 100644 --- a/aria/orchestrator/context/common.py +++ b/aria/orchestrator/context/common.py @@ -15,11 +15,11 @@ """ A common context for both workflow and operation """ +import logging from contextlib import contextmanager from functools import partial from uuid import uuid4 -import logging import jinja2 from aria import logger as aria_logger @@ -59,7 +59,9 @@ class BaseContext(aria_logger.LoggerMixin): self._workdir = workdir def _get_sqla_handler(self): - api_kwargs = self._model._initiator(**self._model._initiator_kwargs) + api_kwargs = {} + if self._model._initiator: + api_kwargs.update(self._model._initiator(**self._model._initiator_kwargs)) api_kwargs.update(**self._model._api_kwargs) return aria_logger.create_sqla_log_handler(**api_kwargs) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c290a16b/aria/orchestrator/context/operation.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/context/operation.py b/aria/orchestrator/context/operation.py index 97a09aa..9dbcc8c 100644 --- a/aria/orchestrator/context/operation.py +++ b/aria/orchestrator/context/operation.py @@ -138,8 +138,8 @@ class RelationshipOperationContext(BaseOperationContext): @property def logging_id(self): - return '{0}:{1}'.format(self.source_node.name or self.source_node.id, - self.target_node.name or self.target_node.id) + return '{0}->{1}'.format(self.source_node.name or self.source_node.id, + self.target_node.name or self.target_node.id) @property def source_node_template(self): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c290a16b/aria/orchestrator/context/workflow.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/context/workflow.py b/aria/orchestrator/context/workflow.py index 63ece3a..00ed974 100644 --- a/aria/orchestrator/context/workflow.py +++ b/aria/orchestrator/context/workflow.py @@ -65,10 +65,6 @@ class WorkflowContext(BaseContext): return execution.id @property - def logging_id(self): - return self._workflow_name - - @property def execution(self): """ The execution model http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c290a16b/aria/orchestrator/workflows/core/task.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflows/core/task.py b/aria/orchestrator/workflows/core/task.py index e9a6d94..f19b1cf 100644 --- a/aria/orchestrator/workflows/core/task.py +++ b/aria/orchestrator/workflows/core/task.py @@ -150,14 +150,6 @@ class OperationTask(BaseTask): self._task_id = operation_task.id self._update_fields = None - @property - def self_logging(self): - return self._ctx.self_logging - - @property - def logger(self): - return self._ctx.logger - @contextmanager def _update(self): """ http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c290a16b/aria/orchestrator/workflows/events_logging.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflows/events_logging.py b/aria/orchestrator/workflows/events_logging.py index 142ef74..73d8994 100644 --- a/aria/orchestrator/workflows/events_logging.py +++ b/aria/orchestrator/workflows/events_logging.py @@ -26,18 +26,19 @@ from .. import events @events.start_task_signal.connect def _start_task_handler(task, **kwargs): - task.logger.debug('Event: Starting task: {task.name}'.format(task=task)) + task.context.logger.debug('Event: Starting task: {task.name}'.format(task=task)) @events.on_success_task_signal.connect def _success_task_handler(task, **kwargs): - task.logger.debug('Event: Task success: {task.name}'.format(task=task)) + task.context.logger.debug('Event: Task success: {task.name}'.format(task=task)) @events.on_failure_task_signal.connect def _failure_operation_handler(task, exception, **kwargs): error = '{0}: {1}'.format(type(exception).__name__, exception) - task.logger.error('Event: Task failure: {task.name} [{error}]'.format(task=task, error=error)) + task.context.logger.error('Event: Task failure: {task.name} [{error}]'.format( + task=task, error=error)) @events.start_workflow_signal.connect http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c290a16b/aria/orchestrator/workflows/executor/thread.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/workflows/executor/thread.py b/aria/orchestrator/workflows/executor/thread.py index 7ae0217..6c59986 100644 --- a/aria/orchestrator/workflows/executor/thread.py +++ b/aria/orchestrator/workflows/executor/thread.py @@ -63,5 +63,5 @@ class ThreadExecutor(BaseExecutor): except BaseException as e: self._task_failed(task, exception=e) # Daemon threads - except BaseException: + except BaseException as e: pass http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c290a16b/aria/storage/modeling/orchestrator_elements.py ---------------------------------------------------------------------- diff --git a/aria/storage/modeling/orchestrator_elements.py b/aria/storage/modeling/orchestrator_elements.py index 47fe49f..e1671f7 100644 --- a/aria/storage/modeling/orchestrator_elements.py +++ b/aria/storage/modeling/orchestrator_elements.py @@ -471,12 +471,10 @@ class TaskBase(ModelMixin): class LogBase(ModelMixin): __tablename__ = 'log' - logger = Column(String) level = Column(String) msg = Column(String) created_at = Column(DateTime, index=True) - prefix = Column(String) - description = Column(String) + actor = Column(String) def __repr__(self): return "{self.created_at}: [{self.level}] @{self.prefix} ->{msg}".format(