Log data from `drone.stderr` to haibu
545681
function onStderr (data) {
      data = data.toString();
      haibu.emit('drone:stderr', 'error', data, meta);

      if (!responded) {
        stderr = stderr.concat(data.split('\n').filter(function (line) { return line.length > 0 }));
      }
    }
893063
def parse_verbose(self, line):
        
        try:
            logging.debug(line)
            (host, pings) = line.split(' : ')
            cnt = 0
            lost = 0
            times = []
            pings = pings.strip().split(' ')
            cnt = len(pings)
            for latency in pings:
                if latency == '-':
                    continue
                times.append(float(latency))

            lost = cnt - len(times)
            if lost:
                loss = lost / float(cnt)
            else:
                loss = 0.0

            rv = {
                'host': host.strip(),
                'cnt': cnt,
                'loss': loss,
                'data': times,
                }
            if times:
                rv['min'] = min(times)
                rv['max'] = max(times)
                rv['avg'] = sum(times) / len(times)
                rv['last'] = times[-1]
            return rv

        except Exception as e:
            logging.error("failed to get data: {}".format(e))
188574
def read_line_stderr(self, time_limit=None):
        
        if self.proc is not None:
            return self.proc.stderr.readline().decode()
        else:
            return None
1002366
def log(logger, level, message):
    """"""

    if logger.parent.name != 'root':
        logger.log(level, message)
    else:
        print(message, file=sys.stderr)
802645
function log () {
    if (argv.stdin && argv.fix) {
      arguments[0] = opts.cmd + ': ' + arguments[0]
      console.error.apply(console, arguments)
    } else {
      console.log.apply(console, arguments)
    }
  }
1182101
def log_last_error(fname, context=None):
    """"""
    fd = open(fname, 'a')
    log_time(fd)
    if context:
        print("Context", file=fd)
        print("-------", file=fd)
        print("", file=fd)
        if PY2:
            print(u' '.join(context).encode('utf-8').strip(), file=fd)
        else:
            print(context, file=fd)
        print("", file=fd)
        print("Traceback", file=fd)
        print("---------", file=fd)
        print("", file=fd)
    traceback.print_exc(file=fd)
    print("", file=fd)
    print("", file=fd)
1211553
def run(url, cmd, log_path, log_level, log_session, force_discovery, print_info):
    """"""
    log_level = log_levels[log_level]
    conn = condoor.Connection("host", list(url), log_session=log_session, log_level=log_level, log_dir=log_path)
    try:
        conn.connect(force_discovery=force_discovery)
        if print_info:
            echo_info(conn)

        for command in cmd:
            result = conn.send(command)
            print("\nCommand: {}".format(command))
            print("Result: \n{}".format(result))
    except (condoor.ConnectionError, condoor.ConnectionAuthenticationError, condoor.ConnectionTimeoutError,
            condoor.InvalidHopInfoError, condoor.CommandSyntaxError, condoor.CommandTimeoutError,
            condoor.CommandError, condoor.ConnectionError) as excpt:
        click.echo(excpt)
    finally:
        conn.disconnect()
    return
678830
def print_stack(pid, include_greenlet=False, debugger=None, verbose=False):
    """"""
    # TextIOWrapper of Python 3 is so strange.
    sys_stdout = getattr(sys.stdout, 'buffer', sys.stdout)
    sys_stderr = getattr(sys.stderr, 'buffer', sys.stderr)

    make_args = make_gdb_args
    environ = dict(os.environ)
    if (
        debugger == 'lldb' or
        (debugger is None and platform.system().lower() == 'darwin')
    ):
        make_args = make_lldb_args
        # fix the PATH environment variable for using built-in Python with lldb
        environ['PATH'] = '/usr/bin:%s' % environ.get('PATH', '')

    tmp_fd, tmp_path = tempfile.mkstemp()
    os.chmod(tmp_path, 0o777)
    commands = []
    commands.append(FILE_OPEN_COMMAND)
    commands.extend(UTILITY_COMMANDS)
    commands.extend(THREAD_STACK_COMMANDS)
    if include_greenlet:
        commands.extend(GREENLET_STACK_COMMANDS)
    commands.append(FILE_CLOSE_COMMAND)
    command = r';'.join(commands)

    args = make_args(pid, command % tmp_path)
    process = subprocess.Popen(
        args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    out, err = process.communicate()
    if verbose:
        sys_stderr.write(b'Standard Output:\n%s\n' % out)
        sys_stderr.write(b'Standard Error:\n%s\n' % err)
        sys_stderr.flush()

    for chunk in iter(functools.partial(os.read, tmp_fd, 1024), b''):
        sys_stdout.write(chunk)
    sys_stdout.write(b'\n')
    sys_stdout.flush()
578241
def print_err(*args, end='\n'):
    
    print(*args, end=end, file=sys.stderr)
    sys.stderr.flush()
51842
def use_absl_log_file(self, program_name=None, log_dir=None):
    """"""
    if FLAGS['logtostderr'].value:
      self.stream = sys.stderr
    else:
      self.start_logging_to_file(program_name=program_name, log_dir=log_dir)
612409
def log_hack
      read_stderr, write_stderr = IO.pipe

      fork do
        write_stderr.close

        read_stderr.each do |l|
          @log.trace "GFS: #{l.chomp.strip}"
        end

        read_stderr.close
      end

      old_stderr = STDERR.clone

      STDERR.reopen(write_stderr)
      STDERR.sync = true

      begin
        # Execute all tasks
        yield if block_given?
      ensure
        STDERR.reopen(old_stderr)
      end

      write_stderr.close
      read_stderr.close

      Process.wait
    end
1219755
def write_to_logfile(logfile, out, err, cmd):
    
    with open(logfile, 'a+') as outfile:
        outfile.write('Command used: {}\n\n'.format(cmd))
        outfile.write('STDOUT: {}\n\n'.format(out))
        outfile.write('STDERR: {}\n\n'.format(err))
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)
869724
def log(host=None, port=None, limit=0):
    """"""
    app.config['HOST'] = first_value(host, app.config.get('HOST',None), '0.0.0.0')
    app.config['PORT'] = int(first_value(port, app.config.get('PORT',None), 5001))
    if app.config['HOST'] == "0.0.0.0": 
        host="127.0.0.1"
    else:
        host = app.config['HOST']
    port = app.config['PORT']    
    try:
        res = requests.get('http://%s:%s/api/log?limit=%s' % (host, port, limit))
        if res.status_code == 200:
            for record in json.loads(res.text):
                if record['level'] >= 30:
                    print(record['msg'], file=sys.stderr)
                else:    
                    print(record['msg'], file=sys.stdinfo)
        else:
            print('web server is not flaskserver', file=sys.stderr)
    except:
        print('web server is not flaskserver or not start', file=sys.stderr)
109786
def stderr_handle():
    """"""
    gpg_stderr = None
    handle = None
    if LOGGER.getEffectiveLevel() > logging.DEBUG:
        handle = open(os.devnull, 'wb')
        gpg_stderr = handle

    return handle, gpg_stderr
376387
def stderr_cm(self):
        
        with open(self._get_stderr_log(), 'a+') as fh:
            msg = '### {} ###\n'.format(self._datetime)
            fh.write(msg)
            fh.flush()

            try:
                yield fh
            except Exception as e:
                self._has_error = True
                fh.write(e.message)
                fh.flush()
                raise
1219472
def attach_log_stream(self):
        
        if self.has_api_logs:
            self.log_stream = self.attach(stdout=True, stderr=True, stream=True)