jmquintana79
4/21/2016 - 6:41 AM

logs

Python library for logging messages

import logging

"""
Homepage manual: https://docs.python.org/2/howto/logging.html

Levels: When it’s used
  DEBUG:	Detailed information, typically of interest only when diagnosing problems.
  INFO:	Confirmation that things are working as expected.
  WARNING:	An indication that something unexpected happened, or indicative of some problem in the near future (e.g. ‘disk space low’). The software is still working as expected.
  ERROR:	Due to a more serious problem, the software has not been able to perform some function.
  CRITICAL:	A serious error, indicating that the program itself may be unable to continue running.

"""

# logging into file log
logging.basicConfig(filename='example.log',level=logging.DEBUG)
logging.info('Start ...')

# logging by screen
logging.basicConfig(level=logging.INFO)
logging.info("Start ...")

# close logger
try:
    logging.flust()
    logging.close()
except:
    pass