Created
August 15, 2019 08:23
-
-
Save agathauy/c14f6d7e8298ef4927ecf2f2530de0b9 to your computer and use it in GitHub Desktop.
logger script
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
# logging | |
import logging | |
# Configure logger | |
#logging.basicConfig(filename="test.log", format='%(filename)s: %(message)s', filemode='w') | |
logPath = "." | |
fileName = "test" | |
logging.basicConfig( | |
level=logging.ERROR, | |
#format="%(asctime)s [%(threadName)-12.12s] [%(levelname)-5.5s] %(message)s", | |
format="%(asctime)s %(message)s", | |
handlers=[ | |
logging.FileHandler("{0}/{1}.log".format(logPath, fileName)), | |
logging.StreamHandler() | |
]) | |
# Create a logger object | |
logger = logging.getLogger() | |
################## | |
# For logging statements example | |
logger.debug("insert data: {}".format(data_ex)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment