Transparent Battery

キリシマがてきとーする場所

ログとか

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import logging
import sys
def main(test=None):
    logger = logging.getLogger(__name__)
    handler = logging.StreamHandler()
    fh = logging.FileHandler('test.log', 'a+')
    handler.setLevel(logging.INFO)
    logger.setLevel(logging.INFO)
    fh.setLevel(logging.INFO)
    logger.addHandler(handler)
    logger.addHandler(fh)

    get_current_frame()
    success_logger(__file__)

def success_logger(txt):
    logger = logging.getLogger(__name__)
    logger.info(txt)

def error_logger(error_class, txt):
    logger = logging.getLogger(__name__)
    logger.error("{0}:{1}".format(error_class.__name__, txt))
    raise error_class("{0}".format(txt))


def get_current_frame():
    func_obj = sys._getframe().f_back
    print('filename: {0}'.format(func_obj.f_code.co_filename))
    print('function: {0}()'.format(func_obj.f_code.co_name))
    print('current_variables:')
    for varname in func_obj.f_locals:
        print("\t\t  {0}: {1}".format(varname, func_obj.f_locals[varname]))
    print('local_variables:')
    print func_obj.f_code.co_names

main()
'''