Skip to content

Instantly share code, notes, and snippets.

View thomasgogo's full-sized avatar

thomas thomasgogo

  • 00:44 (UTC +08:00)
View GitHub Profile
@thomasgogo
thomasgogo / celery_tasks_error_handling.py
Created October 6, 2017 08:58 — forked from darklow/celery_tasks_error_handling.py
Celery tasks error handling example
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):
@thomasgogo
thomasgogo / logback.conf
Created March 16, 2016 07:57 — forked from pcn/logback.conf
trying for a logstash conf file that works with java's logback logger
input {
# file {
# path => ["/var/log/knewton/*/*.log"]
# type => "knewton_logback"
# }
stdin {
type => "knewton_logback"
}
}
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