Created
January 12, 2016 13:53
-
-
Save noahp/f14e6fb6c906b607a273 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
# https://docs.python.org/2/howto/logging-cookbook.html#logging-to-multiple-destinations | |
if not None: | |
# set up logging to screen and file | |
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s', filename='log.log') | |
# define a Handler which writes INFO messages or higher to the sys.stderr | |
console = logging.StreamHandler() | |
console.setLevel(logging.INFO) | |
# set a format which is simpler for console use | |
formatter = logging.Formatter('%(asctime)s %(message)s') | |
# tell the handler to use this format | |
console.setFormatter(formatter) | |
# add the handler to the root logger | |
logging.getLogger('').addHandler(console) | |
else: | |
# set up logging to screen only | |
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s') | |
logging.info("Starting test sequence.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment