title: How to print log messages from external modules to the main Python module's terminal window?
body: <p>I am writing a Python command line program.</p>
  
  <p>There is a main Python script file, acting as the entry point. When user run this script, it will execute a few external Python script files. The external Python script files may also execute other external Python script files. The number of external files is variable.</p>
  
  <p>The Python script will execute external Python scripts using:</p>
  
  <pre><code>p = subprocess.Popen(args)
  
  or
  
  p = subprocess.call(args)
  </code></pre>
  
  <p>When I run the main Python script in a terminal window, it will print real time log messages on the screen when it is running. Now, I would like to get all log messages from all external Python scripts called by the main Python script and print it onto the same terminal window (the terminal window that I use to run the main script).</p>
  
  <p>For example, below are the sequence of script execution:</p>
  
  <pre><code>1.Main-script
      |
      2.Layer-1-script-1
          |
          3.Layer-2-script-1
          |
          4.Layer-2-script-2
          |
      5.Layer-1-script-2
      |
      6.Layer-1-script-3
      |
  7.Main-script(continued)
  </code></pre>
  
  <p>When I run the main script in a terminal window, is it possible that I can get real time log messages on my terminal window like below?</p>
  
  <pre><code>[time-hh-mm-ss][log message from main script]Script is running..
  [time-hh-mm-ss][log message from main script]Calling script layer-1-script-1..
  [time-hh-mm-ss][log message from layer-1-script-1]Script is running..
  [time-hh-mm-ss][log message from layer-1-script-1]Calling script layer-2-script-1..
  [time-hh-mm-ss][log message from layer-2-script-1]Script is running..
  [time-hh-mm-ss][log message from layer-2-script-1]Calling script layer-2-script-2..
  [time-hh-mm-ss][log message from layer-2-script-2]Script is running..
  [time-hh-mm-ss][log message from layer-2-script-2]Calling script layer-1-script-2..
  [time-hh-mm-ss][log message from layer-1-script-2]Script is running..
  [time-hh-mm-ss][log message from layer-1-script-2]Calling script layer-1-script-3..
  [time-hh-mm-ss][log message from layer-2-script-3]Script is running..
  [time-hh-mm-ss][log message from main script]Back to main script. Script is running..
  </code></pre>
  
  <p>Is it possible that I can get a <code>real time log messages</code> like above in the terminal window?</p>