Skip to content

Instantly share code, notes, and snippets.

@boyvinall
Last active September 8, 2015 12:21
Show Gist options
  • Save boyvinall/ed8a55dba262a96a79cd to your computer and use it in GitHub Desktop.
Save boyvinall/ed8a55dba262a96a79cd to your computer and use it in GitHub Desktop.
python logger setup
import logging
logging.basicConfig(level=logging.DEBUG,
format='[%(created)s] p%(process)s {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s',
datefmt='%H:%M:%S',
filename='/path/to/foo-' + time.strftime("%Y%m%d-%H%M") + '.log',
filemode='w')
console = logging.StreamHandler()
console.setLevel(logging.INFO)
formatter = logging.Formatter('%(levelname)s %(message)s')
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
# do stuff....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment