是否存在创建github问题的django记录器的处理程序?

时间:2012-05-23 20:56:54

标签: django logging github-api

是否有django logger的处理程序在创建日志条目时在github上创建问题?如果没有,创建一个会有多难?

1 个答案:

答案 0 :(得分:1)

这不是一个完整的“电池包含”答案,但是,它会让你自己做一点努力。

  1. 创建custom logger
  2. 让自定义记录器在github上创建问题(我使用了下面的脚本)
  3. 创建Github问题的脚本:

    import json
    import requests
    
    def make_issue(title, body=None, assignee=None, milestone=None, labels=None):
        '''Create an issue on github.com using the given parameters.'''
        # Authentication for user filing issue (must have read/write access to
        # repository to add issue to)
        username = 'CHANGEME'
        password = 'CHANGEME'
        # The repository to add this issue to
        repo_owner = 'CHANGEME'
        repo_name = 'CHANGEME'
        # Our url to create issues via POST
        url = 'https://api.github.com/repos/%s/%s/issues' % (repo_owner, repo_name)
        # Create an authenticated session to create the issue
        session = requests.session(auth=(username, password))
        # Create our issue
        issue = {'title': title,
                 'body': body,
                 'assignee': assignee,
                 'milestone': milestone,
                 'labels': labels}
        # Add the issue to our repository
        r = session.post(url, json.dumps(issue))
        if r.status_code == 201:
            print 'Successfully created Issue "%s"' % title
        else:
            print 'Could not create Issue "%s"' % title
            print 'Response:', r.content
    
    make_issue('Issue Title', 'Body text', 'assigned_user', 3, ['bug'])