Created
May 13, 2015 18:38
-
-
Save munro/aea7fbe72589df2d17d5 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
from logentries import LogentriesHandler | |
import logging | |
import time | |
handler = LogentriesHandler(LOGENTRIES_TOKEN) | |
log = logging.getLogger('logentries') | |
log.addHandler(handler) | |
log.setLevel(logging.INFO) | |
log.warn("Warning message") | |
log.info("Info message") | |
import json | |
handler_json = LogentriesHandler(LOGENTRIES_TOKEN) | |
handler_json.setFormatter(logging.Formatter()) # Remove extra formatting so we can send raw JSON | |
log_json = logging.getLogger('logentries_json') | |
log_json.addHandler(handler_json) | |
log_json.setLevel(logging.INFO) | |
log_json.warn(json.dumps({'level': 'warn', 'message': 'warning message'})) | |
log_json.info(json.dumps({'level': 'info', 'message': 'info message'})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment