Documentation
¶
Index ¶
- func AddAttributes(w *JSONFieldsWriter, attrs map[string]interface{})
- func Compress(b []byte) (*bytes.Buffer, error)
- func CompressWithWriter(b []byte, w *gzip.Writer) error
- func MarshalAttributes(ats map[string]interface{}) []byte
- func MarshalOrderedAttributes(attrs map[string]interface{}) []byte
- func Uncompress(b []byte) ([]byte, error)
- type Attributes
- type JSONFieldsWriter
- func (w *JSONFieldsWriter) AddKey(key string)
- func (w *JSONFieldsWriter) BoolField(key string, val bool)
- func (w *JSONFieldsWriter) FloatField(key string, val float64)
- func (w *JSONFieldsWriter) IntField(key string, val int64)
- func (w *JSONFieldsWriter) NoComma()
- func (w *JSONFieldsWriter) RawField(key string, val json.RawMessage)
- func (w *JSONFieldsWriter) StringField(key string, val string)
- func (w *JSONFieldsWriter) WriterField(key string, val JSONWriter)
- type JSONWriter
- type OrderedAttributes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAttributes ¶
func AddAttributes(w *JSONFieldsWriter, attrs map[string]interface{})
AddAttributes writes the attributes to the fields writer.
func Compress ¶
Compress gzips the given input. For better performance use CompressWithWriter with a pooled gzip.Writer.
func CompressWithWriter ¶ added in v0.5.2
CompressWithWriter gzips the given input using a specific writer.
func MarshalAttributes ¶
MarshalAttributes turns attributes into JSON.
func MarshalOrderedAttributes ¶
MarshalOrderedAttributes marshals the given attributes into JSON in alphabetical order.
Types ¶
type Attributes ¶
type Attributes map[string]interface{}
Attributes is used for marshalling attributes to JSON.
func (Attributes) WriteJSON ¶
func (attrs Attributes) WriteJSON(buf *bytes.Buffer)
WriteJSON writes the attributes in JSON.
type JSONFieldsWriter ¶
JSONFieldsWriter helps write JSON objects to a buffer.
func (*JSONFieldsWriter) AddKey ¶
func (w *JSONFieldsWriter) AddKey(key string)
AddKey adds the key for a new object field. A comma is prefixed if another field has previously been added.
func (*JSONFieldsWriter) BoolField ¶
func (w *JSONFieldsWriter) BoolField(key string, val bool)
BoolField adds a bool field to the object.
func (*JSONFieldsWriter) FloatField ¶
func (w *JSONFieldsWriter) FloatField(key string, val float64)
FloatField adds a float field to the object.
func (*JSONFieldsWriter) IntField ¶
func (w *JSONFieldsWriter) IntField(key string, val int64)
IntField adds an int field to the object.
func (*JSONFieldsWriter) NoComma ¶ added in v0.5.0
func (w *JSONFieldsWriter) NoComma()
NoComma ensures that a comma won't be added before the next field this JsonFieldsWriter writes.
func (*JSONFieldsWriter) RawField ¶
func (w *JSONFieldsWriter) RawField(key string, val json.RawMessage)
RawField adds a raw JSON field to the object.
func (*JSONFieldsWriter) StringField ¶
func (w *JSONFieldsWriter) StringField(key string, val string)
StringField adds a string field to the object.
func (*JSONFieldsWriter) WriterField ¶
func (w *JSONFieldsWriter) WriterField(key string, val JSONWriter)
WriterField adds a JSONWriter field to the object.
type JSONWriter ¶
JSONWriter is something that can write JSON to a buffer.
type OrderedAttributes ¶
type OrderedAttributes map[string]interface{}
OrderedAttributes turns attributes into JSON in a fixed order.
func (OrderedAttributes) WriteJSON ¶
func (attrs OrderedAttributes) WriteJSON(buf *bytes.Buffer)
WriteJSON writes the attributes in JSON in a fixed order.