"""
Version: 0.1
Author: freshbin
Date: 2019年8月21日
"""
print("=================================日志模块 start================================================")
import os
import platform
import logging
if platform.platform().startswith('Windows'):
print('os.path:', os.path)
print('HOMEDRIVE:', os.getenv('HOMEDRIVE'))
print('HOMEPATH:', os.getenv('HOMEPATH'))
logging_file = os.path.join(os.getenv('HOMEDRIVE'), os.getenv('HOMEPATH'), 'test.log')
else:
logging_file = os.path.join(os.getenv('HOME'), 'test.log')
print('logging to', logging_file)
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s : %(levelname)s : %(message)s',
filename=logging_file,
filemode='w',
)
logging.debug('Start of the program')
logging.info("Doing something")
logging.warning("Dying now")
print("=================================日志模块 end================================================")