stdlib_logging.py 629 B

12345678910111213141516171819202122232425
  1. import os
  2. import platform
  3. import logging
  4. if platform.platform().startswith('Windows'):
  5. logging_file = os.path.join(os.getenv('HOMEDRIVE'),
  6. os.getenv('HOMEPATH'),
  7. 'test.log')
  8. else:
  9. logging_file = os.path.join(os.getenv('HOME'),
  10. 'test.log')
  11. print("Logging to", logging_file)
  12. logging.basicConfig(
  13. level=logging.DEBUG,
  14. format='%(asctime)s : %(levelname)s : %(message)s',
  15. filename=logging_file,
  16. filemode='w',
  17. )
  18. logging.debug("Start of the program")
  19. logging.info("Doing something")
  20. logging.warning("Dying now")