def setup_logging(name):
logger = logging.getLogger(__name__)<EOL>if '<STR_LIT>' in os.environ:<EOL><INDENT>prefix = os.environ['<STR_LIT>'].strip()<EOL>major_version = sys.version_info[<NUM_LIT:0>]<EOL>logfile = '<STR_LIT>'.format(prefix, major_version, name)<EOL>handler = logging.FileHandler(logfile, '<STR_LIT:w>', '<STR_LIT:utf-8>')<EOL>handler.formatter = logging.Formatter(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>logging.root.addHandler(handler)<EOL>level = logging.INFO<EOL>if '<STR_LIT>' in os.environ:<EOL><INDENT>lvl = getattr(logging,<EOL>os.environ['<STR_LIT>'].strip(),<EOL>level)<EOL>if isinstance(lvl, int):<EOL><INDENT>level = lvl<EOL><DEDENT><DEDENT>logger.setLevel(level)<EOL><DEDENT>
Setup logging according to environment variables.