diff --git a/linspector/tasks/storage/logger.py b/linspector/tasks/storage/logger.py new file mode 100644 index 0000000..b0804b7 --- /dev/null +++ b/linspector/tasks/storage/logger.py @@ -0,0 +1,50 @@ +""" +The Logger task - Logs data to a file + +Copyright (c) 2011-2013 by Johannes Findeisen and Rafael Timmerberg + +This file is part of Linspector (http://linspector.org). + +Linspector is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +""" + +from logging import getLogger + +from linspector.tasks.task import Task + +logger = getLogger(__name__) + + +class LoggerTask(Task): + def __init__(self, **kwargs): + super(LoggerTask, self).__init__(**kwargs) + + args = self.get_arguments() + + if "file" in args: + self.file = args["file"] + else: + raise Exception("There is no file set") + + def needs_arguments(self): + return True + + def execute(self, job_information): + f = open(self.file, 'a') + f.write(job_information.get_response_message() + '\n') + f.close() + + +def create(kwargs): + return LoggerTask(**kwargs) \ No newline at end of file