lib_xml.py のモジュール:
import conf_store
def hello():
print conf_store.logger
conf_store.logger.debug('why')
print 'where'
conf_store.py のモジュール:
#! /usr/bin/python
import os, subprocess, logging, time, shutil, fcntl
import lib_xml
def log():
"""
a log handle
"""
import logging.handlers
global logger
LOG_PATH = "/opt/conf_store.log"
logger = logging.getLogger('conf_store')
logger.setLevel(logging.DEBUG)
ch = logging.handlers.WatchedFileHandler(LOG_PATH)
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)
if __name__ == "__main__":
log()
while(True):
lib_xml.hello()
logger.debug('what')
logger
lib_xml.py と conf_store.pyの間でオブジェクトを共有するには?