This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from celery import Task | |
| from celery.task import task | |
| from my_app.models import FailedTask | |
| from django.db import models | |
| @task(base=LogErrorsTask) | |
| def some task(): | |
| return result | |
| class LogErrorsTask(Task): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| input { | |
| # file { | |
| # path => ["/var/log/knewton/*/*.log"] | |
| # type => "knewton_logback" | |
| # } | |
| stdin { | |
| type => "knewton_logback" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FIELDS = ['cmd', 'command', 'start', 'end', 'delta', 'msg', 'stdout', 'stderr'] | |
| def human_log(res): | |
| if type(res) == type(dict()): | |
| for field in FIELDS: | |
| if field in res.keys(): | |
| # use default encoding, check out sys.setdefaultencoding | |
| print u'\n{0}:\n{1}'.format(field, res[field]) | |
| # or use specific encoding, e.g. utf-8 |