the module of lib_xml.py :
import conf_store
def hello():
print conf_store.logger
conf_store.logger.debug('why')
print 'where'
the module of 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')
How to share the object of logger between lib_xml.py and conf_store.py ?