This will intercept logs and get their output back to the shell.
766104
function captureLogs() {
  'use strict';
  console.log('Now capturing logs');
  var methods = [ 'debug', 'info', 'log', 'warn', 'error' ];
  methods.forEach(function (mthd) {
    var realMethod = 'real' + mthd,
      report = captureLog.bind({}, mthd);
    console[realMethod] = console[mthd];
    console[mthd] = function () {
      report(arguments);
      console.reallog.apply(console, arguments);
    };
  });
}
1311781
def log(self, logfile=None):
        """"""
        if logfile is None:
            logfile = sys.stderr
        tb = self.plaintext.rstrip() + u"\n"
        logfile.write(to_native(tb, "utf-8", "replace"))
1259089
function _logExecOutput(log, process) {
  let stdout = process.stdout || '';
  let stderr = process.stderr || '';

  if (process.platform === 'win32') {
    stdout = stdout.replace(/\r\n/g, '\n');
    stderr = stderr.replace(/\r\n/g, '\n');
  }

  if (stdout) {
    log.trace({ event: 'EXEC_SUCCESS', stdout: true }, stdout);
  }

  if (stderr) {
    log.trace({ event: 'EXEC_SUCCESS', stderr: true }, stderr);
  }

  if (!stdout && !stderr) {
    log.trace({ event: 'EXEC_SUCCESS' }, '');
  }
}
1170996
function proceedWithBackup() {
    if (options.resume) {
      // pick up from existing log file from previous run
      downloadRemainingBatches(options.log, db, ee, start, batchesPerDownloadSession, options.parallelism);
    } else {
      // create new log file and process
      spoolchanges(db, options.log, options.bufferSize, ee, function(err) {
        if (err) {
          ee.emit('error', err);
        } else {
          downloadRemainingBatches(options.log, db, ee, start, batchesPerDownloadSession, options.parallelism);
        }
      });
    }
  }
532212
protected function _logTraffic() {
        if ('testing' !== APPLICATION_ENV) {
            $lastRequest = $this->_client->getLastRequest();
            $lastResponse = $this->_client->getLastResponse();
            $filename = date('Y-m-d').'-gofilex.log';
            $logMessage  = "\n";
            $logMessage .= '[REQUEST]'."\n";
            $logMessage .= $lastRequest."\n\n";
            $logMessage .= '[RESPONSE]'."\n";
            $logMessage .= $lastResponse."\n\n";

            dump($filename, $logMessage);
        }
    }
820150
private synchronized void ungetLogService() {
        doWarnIfClosed = doDebug();
        if (log != null) {
            bc.ungetService(logSR);
            logSR = null;
            log = null;
        }
    }
1124740
def output_traceback(ex):
    """"""
    # Dump full traceback to console.
    output = "".join(traceback.format_exc()).strip()
    for line in output.split('\n'):
        logging.error(line)
    trace_obj = traceback.extract_tb(ex.__traceback__)[-1]
    trace = [basename(trace_obj[0]), trace_obj[1]]
    name = type(ex).__name__
    output = str(ex).replace('\n', ' ')
    msg = "%s in %s on line %s: %s" % (name, trace[0], trace[1], output)
    return (msg, output)
1327411
def invoke(ctx, data_file):
    """"""
    click.echo('invoking')
    response = ctx.invoke(data_file.read())
    log_data = base64.b64decode(response['LogResult'])
    click.echo(log_data)
    click.echo('Response:')
    click.echo(response['Payload'].read())
    click.echo('done')
570138
def log(self, msg, error=False):
        """"""
        output = self.stdout
        if error:
            output = self.stderr

        output.write(msg)
        output.write('\n')
747447
def logs(self):
        """"""
        if self._resources is None:
            self.__init()
        if "logs" in self._resources:
            url = self._url + "/logs"
            return _logs.Log(url=url,
                             securityHandler=self._securityHandler,
                             proxy_url=self._proxy_url,
                             proxy_port=self._proxy_port,
                             initialize=True)
        else:
            return None
756246
def after_log(logger, log_level, sec_format="%0.3f"):
    """"""
    log_tpl = ("Finished call to '%s' after " + str(sec_format) + "(s), "
               "this was the %s time calling it.")

    def log_it(retry_state):
        logger.log(log_level, log_tpl,
                   _utils.get_callback_name(retry_state.fn),
                   retry_state.seconds_since_start,
                   _utils.to_ordinal(retry_state.attempt_number))

    return log_it
454783
def stream_logs(self, stdout=True, stderr=True, tail='all', timeout=10.0):
        
        return stream_logs(
            self.inner(), stdout=stdout, stderr=stderr, tail=tail,
            timeout=timeout)
930917
protected function output()
    {
        // first get content to local var
        $content = $this->getContentRaw();

        // iterate log content
        foreach ($content as $logEntry) {
            // Get color
            $color = $this->getColorByType($logEntry['type']);

            // Show the message
            pre(
                $logEntry['time'].' '.
                '['.$logEntry['type'].'] '.
                $logEntry['fingerprint'].' '.
                $logEntry['message'].
                $this->getLineSeparator(),
                false,
                $color
            );
        }

        // So we can clear the existing log
        $this->clear();
    }
684368
protected function logProcessStandardStreams(): void
    {
        if (!empty($output = $this->process->getIncrementalOutput())) {
            $this->logger->notice('Received data on stdout: {output}', [
                'pid' => $this->processPid,
                'stream' => 'stdout',
                'output' => $output,
            ]);
        }

        if (!empty($errorOutput = $this->process->getIncrementalErrorOutput())) {
            $this->logger->error('Received data on stderr: {output}', [
                'pid' => $this->processPid,
                'stream' => 'stderr',
                'output' => $errorOutput,
            ]);
        }
    }
642635
def follow_logs(instance_log_id, sleep_duration=1):
    
    cur_idx = 0
    job_terminated = False

    while not job_terminated:
        # Get the logs in a loop and log the new lines
        log_file_contents = ResourceClient().get_content(instance_log_id)
        print_output = log_file_contents[cur_idx:]
        # Get the status of the Job from the current log line
        job_terminated = any(terminal_output in print_output for terminal_output in TERMINATION_OUTPUT_LIST)
        cur_idx += len(print_output)
        sys.stdout.write(print_output)
        sleep(sleep_duration)
1219472
def attach_log_stream(self):
        
        if self.has_api_logs:
            self.log_stream = self.attach(stdout=True, stderr=True, stream=True)
816131
function OutputTee(logfileOutput, terminalOutput) {

    this._outputs = [];
    this._outputs[_OUTPUT_TEE_LOGFILE] = logfileOutput;
    this._outputs[_OUTPUT_TEE_TERMINAL] = terminalOutput;
}