MyTetra Share
Делитесь знаниями!
basicConfig
Время создания: 20.05.2017 20:30
Раздел: Python - Модули - logging
Запись: xintrea/mytetra_db_mcold/master/base/1495301456bemvqdrk74/text.html на raw.githubusercontent.com

import logging
import inspect

s = [
1, 2, 3]

logging.basicConfig(
format=u'%(filename)s[LINE:%(lineno)d]# %(levelname)-8s [%(asctime)s] %(message)s', level = logging.DEBUG, filename=u'mylog.log')
#logging.basicConfig(format=u'%(message)s', level = logging.DEBUG, filename=u'mylog.log')
#logging.debug(u'This is a debug message')

#logging.info(u'This is an info message')
#logging.warning(u'This is a warning message')
#logging.error(u'This is an error message')
#logging.critical(u'FATAL message')


def ex_func(func):
eval('{0}()'.format(str(func)))
log()


def func_1():
print("from func_1")


def log(string=None):
if not string == None:
logging.info(
u'{0}'.format(string))
logging.info(
u'{0}'.format(inspect.stack()[1][3].strip()))

if __name__ == '__main__':
ex_func(
'func_1')

test_menu.py[LINE:27]# INFO [2017-05-20 20:15:32,194] log()
test_menu.py[LINE:28]# INFO [2017-05-20 20:22:58,450] ex_func

 
MyTetra Share v.0.59
Яндекс индекс цитирования