Formats a record and serializes it as a JSON str. If record message isnt
        already a dict, initializes a new dict and uses `default_msg_fieldname`
        as a key as the record msg as the value.
160610
def format(self, record: logging.LogRecord) -> str:
        
        msg: Union[str, dict] = record.msg
        if not isinstance(record.msg, dict):
            msg = {self.default_msg_fieldname: msg}

        if record.exc_info:  # type: ignore
            msg["exc_info"] = record.exc_info
        if record.exc_text:  # type: ignore
            msg["exc_text"] = record.exc_text  # type: ignore

        return self.serializer(msg, default=self._default_handler)
990644
def process_raw_frame(self,
                          id=None,
                          msg=None):
        

        # normalize into a dataframe
        df = json_normalize(msg)
        # convert to a flattened dictionary
        dt = json.loads(df.to_json())

        flat_msg = {}

        for k in dt:
            new_key = "raw_{}".format(k)
            flat_msg[new_key] = dt[k]["0"]
            if new_key not in self.raw_keys:
                self.raw_keys[new_key] = k
        # end of capturing all unique keys

        dt["raw_id"] = id
        self.all_raw.append(dt)

        log.debug("RAW data updated:")
        log.debug(self.raw_keys)
        log.debug(self.all_raw)
        log.debug("")

        return flat_msg
1256496
def _generate_create_dict(record, record_type, data, ttl, **kwargs):
        """"""

        # Basic dns record structure
        resource_record = {
            'host': record,
            'data': data,
            'ttl': ttl,
            'type': record_type
        }

        for (key, value) in kwargs.items():
            resource_record.setdefault(key, value)

        return resource_record
1172571
def format(self, value):
        
        if not isinstance(value, Arguments):
            value = value.iteritems()
        return dict((k, self.fields[k].format(v)) for k, v in value)
250724
def serialize_dict(self, msg_dict):
        """"""
        serialized = json.dumps(msg_dict, namedtuple_as_object=False)
        if PY2:
            serialized = serialized.decode("utf-8")
        serialized = "{}\nend\n".format(serialized)
        return serialized
1159478
def deserialize_records(records):
    
    native_records = []
    for record in records:
        parsed = json.loads(record['body'])

        # Is this a DynamoDB stream event?
        if isinstance(parsed, str):
            native_records.append(json.loads(parsed))

        # Is this a subscription message from SNS? If so, skip it:
        elif parsed.get('Type') == 'SubscriptionConfirmation':
            continue

        # Is this from SNS (cross-region request -- SNS messages wrapped in SQS message) -- or an SNS proxied message?
        elif parsed.get('Message'):
            native_records.append(json.loads(parsed['Message']))

        else:
            native_records.append(parsed)

    return native_records
976591
def _RegularMessageToJsonObject(self, message, js):
    """"""
    fields = message.ListFields()

    try:
      for field, value in fields:
        if self.preserving_proto_field_name:
          name = field.name
        else:
          name = field.json_name
        if _IsMapEntry(field):
          # Convert a map field.
          v_field = field.message_type.fields_by_name['value']
          js_map = {}
          for key in value:
            if isinstance(key, bool):
              if key:
                recorded_key = 'true'
              else:
                recorded_key = 'false'
            else:
              recorded_key = key
            js_map[recorded_key] = self._FieldToJsonObject(
                v_field, value[key])
          js[name] = js_map
        elif field.label == descriptor.FieldDescriptor.LABEL_REPEATED:
          # Convert a repeated field.
          js[name] = [self._FieldToJsonObject(field, k)
                      for k in value]
        else:
          js[name] = self._FieldToJsonObject(field, value)

      # Serialize default value if including_default_value_fields is True.
      if self.including_default_value_fields:
        message_descriptor = message.DESCRIPTOR
        for field in message_descriptor.fields:
          # Singular message fields and oneof fields will not be affected.
          if ((field.label != descriptor.FieldDescriptor.LABEL_REPEATED and
               field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE) or
              field.containing_oneof):
            continue
          if self.preserving_proto_field_name:
            name = field.name
          else:
            name = field.json_name
          if name in js:
            # Skip the field which has been serailized already.
            continue
          if _IsMapEntry(field):
            js[name] = {}
          elif field.label == descriptor.FieldDescriptor.LABEL_REPEATED:
            js[name] = []
          else:
            js[name] = self._FieldToJsonObject(field, field.default_value)

    except ValueError as e:
      raise SerializeToJsonError(
          'Failed to serialize {0} field: {1}.'.format(field.name, e))

    return js
275262
def format_graylog_v0(self, record):
        '''
        
        '''
        message_dict = {
            'message': record.getMessage(),
            'timestamp': self.formatTime(record),
            # Graylog uses syslog levels, not whatever it is Python does...
            'level': syslog_levels.get(record.levelname, 'ALERT'),
            'tag': self.tag
        }

        if record.exc_info:
            exc_info = self.formatException(record.exc_info)
            message_dict.update({'full_message': exc_info})

        # Add any extra attributes to the message field
        for key, value in six.iteritems(record.__dict__):
            if key in ('args', 'asctime', 'bracketlevel', 'bracketname', 'bracketprocess',
                       'created', 'exc_info', 'exc_text', 'id', 'levelname', 'levelno', 'msecs',
                       'msecs', 'message', 'msg', 'relativeCreated', 'version'):
                # These are already handled above or explicitly pruned.
                continue

            if isinstance(value, (six.string_types, bool, dict, float, int, list, types.NoneType)):  # pylint: disable=W1699
                val = value
            else:
                val = repr(value)
            message_dict.update({'{0}'.format(key): val})
        return message_dict
1308264
def format(self, record):
        
        if not hasattr(record, "type"):
            record.type = "   "
        return self._formatter.format(record)
653754
def format(self, record):
        """"""
        format_orig = self._fmt
        self._fmt = self.get_level_fmt(record.levelno)
        record.prefix = self.prefix
        record.plugin_id = self.plugin_id
        result = logging.Formatter.format(self, record)
        self._fmt = format_orig
        return result
1161123
public int initForMessage(Rec record)
    {
        int iErrorCode = Constant.NORMAL_RETURN;
        if ((this.getKeyInformation() & DONT_INIT) != 0)
            return iErrorCode;  // Don't clear this field
        Field field = record.getField(this.getKey());
        if (field != null)
            return field.initField(true);
        return iErrorCode;
    }
881295
def format(self, record):
        
        return {
            'timestamp': int(float(record.created or time.time()) * 1000),
            'message': record.msg or '',
            'level': record.levelname or 'DEBUG',
        }
681940
async def load_message(obj, msg_type, msg=None, field_archiver=None):
    
    msg = msg_type() if msg is None else msg

    fields = msg_type.f_specs() if msg_type else msg.__class__.f_specs()
    for field in fields:
        await load_message_field(obj, msg, field, field_archiver=field_archiver)

    return msg
639057
function formatRecordToString(record, style) {
  const parts = [];

  if (record.displayName) {
    parts.push(style(['gray-light'], record.displayName));
  } else if (record.key) {
    parts.push(style(['gray-light'], record.key));
  }

  if (record.datetime) {
    parts.push(style(['gray', 'bold'], record.datetime.toTimeString().split(' ')[0]));
    /* new Date().toFormat('HH24:MI:SS') */
  }

  let message = record.symbol || levelToSymbol[record.level];
  const styles = record.styles || levelToStyles[record.level];

  if (record.message) {
    if (message) {
      message += ` ${record.message}`;
    } else {
      message = record.message;
    }
  }

  if (message) {
    if (styles) {
      message = style(styles, message);
    }

    parts.push(message);
  }

  const formatRecordObject = function formatRecordObject(key, object, styles) {
    if (!object) {
      return;
    }

    const stringObject = formatObject(object, style, styles);

    if (!stringObject) {
      return;
    }

    parts.push(stringObject);
  };

  formatRecordObject('metadata', record.metadata, record.metadataStyles);
  formatRecordObject('extra', record.extra, undefined);
  formatRecordObject('context', record.context, undefined);
  return parts.join(' ');
}
565830
async def dump_message_field(obj, msg, field, field_archiver=None):
    
    fname, ftype, params = field[0], field[1], field[2:]
    fvalue = getattr(msg, fname, None)
    field_archiver = field_archiver if field_archiver else dump_field
    return await field_archiver(eref(obj, fname, True), fvalue, ftype, params)
839937
def format(self, record):
        """"""
        if record.levelno == logging.DEBUG:
            string = Back.WHITE + Fore.BLACK + ' debug '
        elif record.levelno == logging.INFO:
            string = Back.BLUE + Fore.WHITE + ' info '
        elif record.levelno == logging.WARNING:
            string = Back.YELLOW + Fore.BLACK + ' warning '
        elif record.levelno == logging.ERROR:
            string = Back.RED + Fore.WHITE + ' error '
        elif record.levelno == logging.CRITICAL:
            string = Back.BLACK + Fore.WHITE + ' critical '
        else:
            string = ''
        return '{none}{string}{none} {super}'.format(
            none=Style.RESET_ALL, string=string, super=super().format(record))
147032
def format(self, record):
        
        message = super(ContainerEngineHandler, self).format(record)
        return format_stackdriver_json(record, message)