Skip to content

Instantly share code, notes, and snippets.

@munro
Created May 13, 2015 18:38
Show Gist options
  • Save munro/aea7fbe72589df2d17d5 to your computer and use it in GitHub Desktop.
Save munro/aea7fbe72589df2d17d5 to your computer and use it in GitHub Desktop.
#!/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