Documentation ¶
Index ¶
- Constants
- Variables
- func Encode(e *Event) (b []byte, err error)
- type Event
- func (e *Event) Decode(b []byte)
- func (*Event) Descriptor() ([]byte, []int)deprecated
- func (e *Event) Encode() []byte
- func (x *Event) GetLevel() Level
- func (x *Event) GetMeta() *structpb.Struct
- func (x *Event) GetMsg() string
- func (x *Event) GetPrefix() string
- func (x *Event) GetSub() string
- func (x *Event) GetTime() *timestamppb.Timestamp
- func (e *Event) Marshal() ([]byte, error)
- func (*Event) ProtoMessage()
- func (x *Event) ProtoReflect() protoreflect.Message
- func (x *Event) Reset()
- func (x *Event) String() string
- func (e *Event) Unmarshal(b []byte) error
- type EventBuilder
- func (b *EventBuilder) Build() *Event
- func (b *EventBuilder) CallStack(all bool) *EventBuilder
- func (b *EventBuilder) Level(l Level) *EventBuilder
- func (b *EventBuilder) Message(m string) *EventBuilder
- func (b *EventBuilder) Metadata(m map[string]interface{}) *EventBuilder
- func (b *EventBuilder) Prefix(p string) *EventBuilder
- func (b *EventBuilder) Sub(s string) *EventBuilder
- type Field
- type Level
- func (Level) Descriptor() protoreflect.EnumDescriptor
- func (x Level) Enum() *Level
- func (Level) EnumDescriptor() ([]byte, []int)deprecated
- func (l Level) Int() int32
- func (x Level) Number() protoreflect.EnumNumber
- func (x Level) String() string
- func (Level) Type() protoreflect.EnumType
- func (x *Level) UnmarshalJSON(b []byte) errordeprecated
Constants ¶
const ( Default_Event_Prefix = string("log") Default_Event_Level = Level_info )
Default values for Event fields.
Variables ¶
var ( Level_name = map[int32]string{ 0: "trace", 1: "debug", 2: "info", 3: "warn", 4: "error", 5: "fatal", 9: "panic", } Level_value = map[string]int32{ "trace": 0, "debug": 1, "info": 2, "warn": 3, "error": 4, "fatal": 5, "panic": 9, } )
Enum value maps for Level.
var File_proto_event_proto protoreflect.FileDescriptor
Functions ¶
Types ¶
type Event ¶
type Event struct { Time *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=time" json:"time,omitempty"` Prefix *string `protobuf:"bytes,2,opt,name=prefix,def=log" json:"prefix,omitempty"` Sub *string `protobuf:"bytes,3,opt,name=sub" json:"sub,omitempty"` Level *Level `protobuf:"varint,4,opt,name=level,enum=event.Level,def=2" json:"level,omitempty"` Msg *string `protobuf:"bytes,5,req,name=msg" json:"msg,omitempty"` Meta *structpb.Struct `protobuf:"bytes,6,opt,name=meta" json:"meta,omitempty"` // contains filtered or unexported fields }
func Decode ¶
Decode function will take in a slice of bytes and convert it to an Event protobuf, returning this and an error if any.
func (*Event) Decode ¶
Decode method is similar to Event.Unmarshal, but it does not return any errors
func (*Event) Descriptor
deprecated
func (*Event) Encode ¶
Encode method is similar to Event.Marshal(), but it does not return any errors
func (*Event) GetTime ¶
func (x *Event) GetTime() *timestamppb.Timestamp
func (*Event) Marshal ¶
Marshal method will convert the protobuf Event into a slice of bytes, also returning potential errors in the convertion
func (*Event) ProtoMessage ¶
func (*Event) ProtoMessage()
func (*Event) ProtoReflect ¶
func (x *Event) ProtoReflect() protoreflect.Message
type EventBuilder ¶
type EventBuilder struct { BTime *time.Time BPrefix *string BSub *string BLevel *Level BMsg string BMetadata *map[string]interface{} }
EventBuilder struct describes the elements in an Events's builder, which will be the target of different changes until its `Build()` method is called -- returning then a pointer to an Events object
func New ¶
func New() *EventBuilder
New function is the initializer of an EventBuilder. From this call, further EventBuilder methods can be chained since they all return pointers to the same
This builder returns an EventBuilder struct with initialized pointers to its elements, which is exactly the same implementation as the protobuf message, without protobuf-specific data types
func (*EventBuilder) Build ¶
func (b *EventBuilder) Build() *Event
Build method will create a new timestamp, review all elements in the `EventBuilder`, apply any defaults to non-defined elements, and return a pointer to an Event
func (*EventBuilder) CallStack ¶
func (b *EventBuilder) CallStack(all bool) *EventBuilder
CallStack method will grab the current call stack, and add it as a "callstack" object in the EventBuilder's metadata.
func (*EventBuilder) Level ¶
func (b *EventBuilder) Level(l Level) *EventBuilder
Level method will set the level element in the EventBuilder with LogLevel l, and return the builder
func (*EventBuilder) Message ¶
func (b *EventBuilder) Message(m string) *EventBuilder
Message method will set the message element in the EventBuilder with string m, and return the builder
func (*EventBuilder) Metadata ¶
func (b *EventBuilder) Metadata(m map[string]interface{}) *EventBuilder
Metadata method will set (or add) the metadata element in the EventBuilder with map m, and return the builder
func (*EventBuilder) Prefix ¶
func (b *EventBuilder) Prefix(p string) *EventBuilder
Prefix method will set the prefix element in the EventBuilder with string p, and return the builder
func (*EventBuilder) Sub ¶
func (b *EventBuilder) Sub(s string) *EventBuilder
Sub method will set the sub-prefix element in the EventBuilder with string s, and return the builder
type Field ¶
type Field map[string]interface{}
Field type is a generic type to build Event Metadata
func (Field) Encode ¶
Encode method is similar to Field.ToStructPB(), but it does not return any errors.
func (Field) ToStructPB ¶
ToStructPB method will convert the metadata in the protobuf Event as a pointer to a structpb.Struct, returning this and an error if any.
The metadata (a map[string]interface{}) is converted to JSON (bytes), and this data is unmarshalled into a *structpb.Struct object.
type Level ¶
type Level int32
func (Level) Descriptor ¶
func (Level) Descriptor() protoreflect.EnumDescriptor
func (Level) EnumDescriptor
deprecated
func (Level) Int ¶
Int method is used to grab the int32 enum value of the Level in the Event
This value may be used for log-level-filtering
func (Level) Number ¶
func (x Level) Number() protoreflect.EnumNumber
func (Level) Type ¶
func (Level) Type() protoreflect.EnumType