Source code for exopy.tasks.tasks.util.log_task

# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright 2015-2018 by Exopy Authors, see AUTHORS for more details.
#
# Distributed under the terms of the BSD license.
#
# The full license is in the file LICENCE, distributed with this software.
# -----------------------------------------------------------------------------
"""Logging Task.

"""
from atom.api import (Str, set_default)
import logging

from ..base_tasks import SimpleTask


[docs]class LogTask(SimpleTask): """ Task logging a message. Loopable. """ #: Message to log when the task is executed. message = Str().tag(pref=True, fmt=True) database_entries = set_default({'message': ''}) wait = set_default({'activated': True}) # Wait on all pools by default.
[docs] def perform(self, *args, **kwargs): """ Format the message and log it. """ mess = self.format_string(self.message) self.write_in_database('message', mess) logging.info(mess) return True