Read messages from .log file
332931
def read(self, log_file):
        
        if os.path.isdir(os.path.dirname(log_file)) and os.path.isfile(log_file):
            with open(log_file, 'r') as LogFile:
                data = LogFile.readlines()
                data = "".join(line for line in data)
        else:
            data = ''
        return data
901965
def log_to_file(self, message):
        """"""

        with self.build_fs.open(self.log_file, 'a+') as f:
            f.write(unicode(message + '\n'))
1220724
def read_file(self, fileob):
        """"""
        msg = message_from_file(fileob)
        self._fields['Metadata-Version'] = msg['metadata-version']

        # When reading, get all the fields we can
        for field in _ALL_FIELDS:
            if field not in msg:
                continue
            if field in _LISTFIELDS:
                # we can have multiple lines
                values = msg.get_all(field)
                if field in _LISTTUPLEFIELDS and values is not None:
                    values = [tuple(value.split(',')) for value in values]
                self.set(field, values)
            else:
                # single line
                value = msg[field]
                if value is not None and value != 'UNKNOWN':
                    self.set(field, value)
        self.set_metadata_version()
62682
def from_file_msg(cls, fp):
        
        log.debug("Parsing email from file Outlook")
        f, _ = msgconvert(fp)
        return cls.from_file(f, True)
221753
def handle_log_message(msg):  # pylint: disable=useless-return
    """"""
    msg.gateway.can_log = True
    _LOGGER.debug(
        'n:%s c:%s t:%s s:%s p:%s', msg.node_id, msg.child_id, msg.type,
        msg.sub_type, msg.payload)
    return None
149811
def _log(self, message, stream, color=None, newline=False):
        '''
        
        '''

        if color and self.color_term:
            colorend = Logger.COLOR_END
        else:
            color = colorend = ''

        stream.write('{color}{message}{colorend}\n'.format(
            color=color,
            message=message,
            colorend=colorend
        ))

        if newline:
            sys.stdout.write('\n')

        stream.flush()
938638
def _log(self, message):
        
        self._logger.debug("{}: {}".format(self.name, message))
942333
function logMessage(time, path, message, mode) {
  if (config.logToConsole) {
    console.log(mode ? '['+mode+']' : '', path, message)
  }
  if (dataFile) {
    dataFile.log(time, path, message, mode)
  }
}
437094
def log(self, msg):
        ""
        if not isinstance(msg, unicode):
            msg = unicode(msg, 'utf8', 'ignore')
        if not self.Log:
            self.Log = StringIO()
        self.Log.write(msg)
        self.Log.write('\n\r')
        if DEBUG:
            warnings.warn(msg)
1046734
def tail(ctx):
    """"""
    click.echo('tailing logs')
    for e in ctx.tail()[-10:]:
        ts = datetime.utcfromtimestamp(e['timestamp'] // 1000).isoformat()
        click.echo("{}: {}".format(ts, e['message']))
    click.echo('done')
852013
def _read_message(self):
        
        # first 4 bytes is Big-Endian payload length
        payload_info = self._read_bytes_from_socket(4)
        read_len = unpack(">I", payload_info)[0]

        # now read the payload
        payload = self._read_bytes_from_socket(read_len)

        # pylint: disable=no-member
        message = cast_channel_pb2.CastMessage()
        message.ParseFromString(payload)

        return message
582256
def _read_message(self):
    
    size = int(self.buf.read_line().decode("utf-8"))
    return self.buf.read(size).decode("utf-8")
1204431
def _read_message(self):
        
        line = self._rfile.readline()

        if not line:
            return None

        content_length = self._content_length(line)

        # Blindly consume all header lines
        while line and line.strip():
            line = self._rfile.readline()

        if not line:
            return None

        # Grab the body
        return self._rfile.read(content_length)
7222
def log(self, msg, *args):
        """"""
        if args:
            msg %= args
        click.echo(msg, file=sys.stderr)
811753
def log_to_json(log):
    """"""
    return [log.timestamp.isoformat()[:22],
            log.level, log.process, log.message]
22467
def run(self):
        
        message_buffer = b""
        while self.running:
            try:
                message_buffer += self.source.read_logs()
            except DataSourceError as e:
                if self.running:
                    LOG.warn("Can't read logs from data source -- stopping: %s", e)
                break
            except NotImplementedError as e:
                LOG.info("%s doesn't support logging" % self)
                break

            while True:
                if "\x00" not in message_buffer:
                    break
                record, _, remainder = message_buffer.partition(b"\x00")
                self.record(record)
                message_buffer = remainder
917382
def getLinesFromLogFile(stream):
    
    stream.flush()
    stream.seek(0)
    lines = stream.readlines()
    return lines