Skip to content

Instantly share code, notes, and snippets.

@agathauy
Created August 15, 2019 08:23
Show Gist options
  • Save agathauy/c14f6d7e8298ef4927ecf2f2530de0b9 to your computer and use it in GitHub Desktop.
Save agathauy/c14f6d7e8298ef4927ecf2f2530de0b9 to your computer and use it in GitHub Desktop.
logger script
# 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