Created
March 4, 2016 15:06
-
-
Save ericfourrier/2bf6684101ecb330ab36 to your computer and use it in GitHub Desktop.
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 characters
import logging | |
# logging.getLogger(type(self).__name__) if you have a lot of class | |
log = logging.getLogger() # 'root' Logger | |
console = logging.StreamHandler() # logging to console | |
csv_handler = logging.FileHandler('logs.csv') | |
template_log = '%(asctime)s,%(levelname)s,%(processName)s,%(filename)s,%(lineno)s,%(message)s' #csv | |
console.setFormatter(logging.Formatter(template_log)) | |
log.addHandler(console) # prints to console. | |
log.addHandler(csv_handler) # save to csv gile | |
log.setLevel(logging.DEBUG) # DEBUG or above |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment