# Path: conjureup/app_config.py
# class AppConfig:
#     def __setattr__(self, name, value):
#     def _internal_state_key(self):
#     def all_steps(self):
#     def has_bundle_modifications(self):
#     async def save(self):
#     async def restore(self):
# 
# Path: conjureup/log.py
# def setup_logging(app, logfile, debug=True):
#     old_factory = logging.getLogRecordFactory()
# 
#     def spell_record_factory(*args, **kwargs):
#         record = old_factory(*args, **kwargs)
#         if record.name != 'conjure-up':
#             record.filename = '{}: {}'.format(record.name, record.filename)
#         spell_name = app.config.get('spell', consts.UNSPECIFIED_SPELL)
#         record.name = 'conjure-up/{}'.format(spell_name)
#         return record
# 
#     logging.setLogRecordFactory(spell_record_factory)
# 
#     cmdslog = TimedRotatingFileHandler(logfile,
#                                        when='D',
#                                        interval=1,
#                                        backupCount=7)
#     cmdslog.setFormatter(logging.Formatter(
#         "%(asctime)s [%(levelname)s] %(name)s - "
#         "%(filename)s:%(lineno)d - %(message)s"))
# 
#     root_logger = logging.getLogger()
#     app_logger = logging.getLogger('conjure-up')
# 
#     if debug:
#         app_logger.setLevel(logging.DEBUG)
#         root_logger.setLevel(logging.DEBUG)
#     else:
#         # always use DEBUG level for app, for now
#         app_logger.setLevel(logging.DEBUG)
#         root_logger.setLevel(logging.INFO)
# 
#     root_logger.addHandler(cmdslog)
#     if os.path.exists('/dev/log'):
#         st_mode = os.stat('/dev/log').st_mode
#         if stat.S_ISSOCK(st_mode):
#             syslog_h = SysLogHandler(address='/dev/log')
#             syslog_h.set_name('conjure-up')
#             app_logger.addHandler(syslog_h)
# 
#     return app_logger


import os
import sys
from conjureup.app_config import app
from conjureup.log import setup_logging


CACHEDIR = os.getenv('CONJURE_UP_CACHEDIR',
                     os.path.expanduser('~/.cache/conjure-up'))
SPELL_NAME = os.getenv('CONJURE_UP_SPELL', '_unspecified_spell')
LOGFILE = os.path.join(CACHEDIR, '{spell}.log'.format(spell=SPELL_NAME))

app.config = {'metadata': None,
              'spell': SPELL_NAME}

# Path: conjureup/app_config.py
# class AppConfig:
#     def __setattr__(self, name, value):
#     def _internal_state_key(self):
#     def all_steps(self):
#     def has_bundle_modifications(self):
#     async def save(self):
#     async def restore(self):
# 
# Path: conjureup/log.py
# def setup_logging(app, logfile, debug=True):
#     old_factory = logging.getLogRecordFactory()
# 
#     def spell_record_factory(*args, **kwargs):
#         record = old_factory(*args, **kwargs)
#         if record.name != 'conjure-up':
#             record.filename = '{}: {}'.format(record.name, record.filename)
#         spell_name = app.config.get('spell', consts.UNSPECIFIED_SPELL)
#         record.name = 'conjure-up/{}'.format(spell_name)
#         return record
# 
#     logging.setLogRecordFactory(spell_record_factory)
# 
#     cmdslog = TimedRotatingFileHandler(logfile,
#                                        when='D',
#                                        interval=1,
#                                        backupCount=7)
#     cmdslog.setFormatter(logging.Formatter(
#         "%(asctime)s [%(levelname)s] %(name)s - "
#         "%(filename)s:%(lineno)d - %(message)s"))
# 
#     root_logger = logging.getLogger()
#     app_logger = logging.getLogger('conjure-up')
# 
#     if debug:
#         app_logger.setLevel(logging.DEBUG)
#         root_logger.setLevel(logging.DEBUG)
#     else:
#         # always use DEBUG level for app, for now
#         app_logger.setLevel(logging.DEBUG)
#         root_logger.setLevel(logging.INFO)
# 
#     root_logger.addHandler(cmdslog)
#     if os.path.exists('/dev/log'):
#         st_mode = os.stat('/dev/log').st_mode
#         if stat.S_ISSOCK(st_mode):
#             syslog_h = SysLogHandler(address='/dev/log')
#             syslog_h.set_name('conjure-up')
#             app_logger.addHandler(syslog_h)
# 
#     return app_logger


# Path: conjureup/hooklib/writer.py
import os
import sys
from conjureup.app_config import app
from conjureup.log import setup_logging



CACHEDIR = os.getenv('CONJURE_UP_CACHEDIR',
                     os.path.expanduser('~/.cache/conjure-up'))
SPELL_NAME = os.getenv('CONJURE_UP_SPELL', '_unspecified_spell')
LOGFILE = os.path.join(CACHEDIR, '{spell}.log'.format(spell=SPELL_NAME))

app.config = {'metadata': None,
              'spell': SPELL_NAME}

log = setup_logging(app, LOGFILE, True)