python debug mode, also can print logs to log file

 

place this on top

import logging
logging.basicConfig(filename='/var/log/custom.log', level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
logging.debug('this is a debug message.')

place your debug message anywhere you like :

logger.debug('this is the array: %s',sys.argv[1])

in this case, “%s” will show array from “sys.argv[1]”