This file contains 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
import re | |
def url_matcher(): | |
""" | |
See: http://daringfireball.net/2010/07/improved_regex_for_matching_urls | |
""" | |
return re.compile( | |
ur"""(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)""" | |
ur"""(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+""" | |
ur"""(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()""" |
This file contains 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
import redis | |
import logging | |
class RedisLogHandler: | |
"""Log handler for logging logs in some redis list | |
""" | |
def __init__(self, host = None, port = None, db = 0, log_key = 'log_key'): | |
self._formatter = logging.Formatter() | |
self._redis = redis.Redis(host = host or 'localhost', port = port or 6379, db = db) | |
self._redis_list_key = log_key |