Jason R. Coombs avatar Jason R. Coombs committed 8901eb8 Draft

Use a global variable for the logger

Comments (0)

Files changed (1)


 HOSTNAME = os.environ.get('EMI_ME')
+logger = logging.getLogger('em.emi.parent')
 def get_app_info(sock):
-    logger = logging.getLogger('em.emi.parent')
     ret = sock.recv(65536)
     if not ret:
         logger.info('Server closed connection before launch.')
     return app_info, buf
 def sendsig(child, sig):
-    logger = logging.getLogger('em.emi.parent')
     signal_name = {signal.SIGKILL: 'KILL', signal.SIGTERM: 'TERM'}.get(
         sig, 'SIG%s' % sig)
     logger.debug('Sending %s signal to child process.' % signal_name)
     os.kill(child, sig)
 def process_server_commands(sock, buf, child):
-    logger = logging.getLogger('em.emi.parent')
     while True:
         while '\n' not in buf:
     import eggmonster.internal_log
     eggmonster.internal_log.configure(debug, app_id)
-    logger = logging.getLogger('em.emi.parent')
-    pid = os.getpid()
         _main(app_name, num, spawn_app, extra_args)
-        if pid != os.getpid():
-            logger = logging.getLogger('em.emi.child')
 def _main(app_name, num, spawn_app, extra_args):
-    logger = logging.getLogger('em.emi.parent')
     master_user = os.environ['EMI_USER']
     master_uid = pwd.getpwnam(master_user)[2]
         os.WEXITSTATUS(res), os.WIFSIGNALED(res))
 def run_app(pkginfo, entry_point, env, num, spawn_app, extra_args):
-    logger = logging.getLogger('em.emi.parent')
     if not spawn_app:
         pid = os.fork()
         if pid:
             logger.debug('Spawned child process with pid %s.' % pid)
             return pid
-    logger = logging.getLogger('em.emi.child')
+    # update the logger to indicate we're now in a child process
+    globals().update(logger = logging.getLogger('em.emi.child'))
     logger.debug('About to locate entry point "%s" in package "%s".',
         (spawn_app or entry_point), pkginfo)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.