-
-
Save mannysz/4ac618dead982f909f4b24694282a20c to your computer and use it in GitHub Desktop.
Revisions
-
bwhaley revised this gist
Mar 6, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,4 +5,4 @@ logging.config.dictConfig(sumologger.LOGGING) logger = logging.getLogger("sumologger") logger.debug("Nifty log message") -
bwhaley revised this gist
Mar 6, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,6 @@ import sumologger from sumologger import SumoHTTPHandler logging.config.dictConfig(sumologger.LOGGING) logger = logging.getLogger("sumologger") logger.debug("sumologger") -
bwhaley revised this gist
Mar 6, 2014 . 2 changed files with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,5 +4,5 @@ from sumologger import SumoHTTPHandler logging.config.dictConfig(loggingconfig.LOGGING) logger = logging.getLogger("sumologger") logger.debug("sumologger") 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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ # http://help.sumologic.com/Help/Default.htm#Uploading_Files_to_an_HTTP_Source.htm class SumoHTTPHandler(logging.Handler): def __init__(self, url, host="collectors.sumologic.com", name=None, compressed=False): """ Similar to HTTPHandler but with some custom Sumo-friendly headers """ @@ -21,7 +21,7 @@ def emit(self, record): h = httplib.HTTPS(host) url = self.url data = urllib.quote(self.format(record)) sep = "?" url = url + "%c%s" % (sep, data) h.putrequest("GET", url) h.putheader("Host", host) -
bwhaley revised this gist
Mar 6, 2014 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,8 @@ import logging.handlers # GET method for sending data to Sumo HTTP Source # http://help.sumologic.com/Help/Default.htm#Uploading_Files_to_an_HTTP_Source.htm class SumoHTTPHandler(logging.Handler): def __init__(self, url, host='collectors.sumologic.com', name=None, compressed=False): """ -
bwhaley created this gist
Mar 6, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ import logging import logging.config import sumologger from sumologger import SumoHTTPHandler logging.config.dictConfig(loggingconfig.LOGGING) logger = logging.getLogger('test') logger.debug("test") 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ import logging.handlers class SumoHTTPHandler(logging.Handler): def __init__(self, url, host='collectors.sumologic.com', name=None, compressed=False): """ Similar to HTTPHandler but with some custom Sumo-friendly headers """ logging.Handler.__init__(self) self.host = host self.url = url self.name = name self.compressed = compressed def emit(self, record): try: import httplib, urllib host = self.host h = httplib.HTTPS(host) url = self.url data = urllib.quote(self.format(record)) sep = '?' url = url + "%c%s" % (sep, data) h.putrequest("GET", url) h.putheader("Host", host) if self.compressed: h.putheader("Content-Encoding", "gzip") if self.name: h.putheader("X-Sumo-Name", self.name) h.endheaders() h.getreply() #can't do anything with the result except (KeyboardInterrupt, SystemExit): raise except: self.handleError(record) LOGGING = { 'version': 1, 'handlers': { 'sumo':{ 'level': "DEBUG", 'class': '__main__.SumoHTTPHandler', 'url': '/receiver/v1/.....', #Replace with your custom Sumo Hosted URL } }, 'loggers': { 'sumologger': { 'handlers': ['sumo'], 'level': 'DEBUG' } } }