Documentation
¶
Index ¶
- Variables
- type JSONMessage
- func (j *JSONMessage) Add(key string, value interface{})
- func (j *JSONMessage) Bytes() []byte
- func (j *JSONMessage) IsDebug() bool
- func (j JSONMessage) Message(m ...interface{})
- func (j JSONMessage) Messagef(format string, m ...interface{})
- func (j *JSONMessage) PrettyBytes() []byte
- func (j *JSONMessage) PrettyString() string
- func (j *JSONMessage) SetCrit()
- func (j *JSONMessage) SetDebug()
- func (j *JSONMessage) SetInfo()
- func (j *JSONMessage) SetWarn()
- func (j *JSONMessage) String() string
- type JSONTimeStamper
Constants ¶
This section is empty.
Variables ¶
var ( // JSONTimeStampKey is used to write the time stamp in json messages JSONTimeStampKey = "timestamp" // JSONLevelKey is used to write the log message concern level. JSONLevelKey = "level" // JSONMessageKey is used as the log message key in the JSON structure JSONMessageKey = "log_message" // JSONTimeStampFunc is a override function to set the timestamp to what the user wants. // It must retrun a string which allows many formats to fit in. // By default the time stamp is a epoch nano number // Can be set by a init function in a higher level package. JSONTimeStampFunc JSONTimeStamper )
Functions ¶
This section is empty.
Types ¶
type JSONMessage ¶
type JSONMessage struct {
// contains filtered or unexported fields
}
JSONMessage is a structure that will contain the message that you want to send.
func (*JSONMessage) Add ¶
func (j *JSONMessage) Add(key string, value interface{})
Add adds on the key that you want to add your message. This can be anything you want.
func (*JSONMessage) Bytes ¶
func (j *JSONMessage) Bytes() []byte
Bytes returns the []byte representation of your message. If there is a error decoding your message it will still return a []byte but will contain the error message in the form of {"Error": "message"}.
func (*JSONMessage) IsDebug ¶
func (j *JSONMessage) IsDebug() bool
IsDebug will return a bool which will indicate that the message is a debug message.
func (JSONMessage) Message ¶
func (j JSONMessage) Message(m ...interface{})
Message sets the message key with what you pass in. It works like fmt.Sprint.
func (JSONMessage) Messagef ¶
func (j JSONMessage) Messagef(format string, m ...interface{})
Messagef sets the message key with what you pass in but also allows for string formatting. It works like fmt.Sprintf.
func (*JSONMessage) PrettyBytes ¶
func (j *JSONMessage) PrettyBytes() []byte
PrettyBytes returns the []byte representation of your message with some json indentation to make it east to read. If there is a error decoding your message it will still return a []byte but will contain the error message in the form of {\n "Error": "message"\n}.
func (*JSONMessage) PrettyString ¶
func (j *JSONMessage) PrettyString() string
PrettyString returns the string presentation of your message. If there is a error decoding your message it will still return a string but will contain the error message in the form of {\n "Error": "message"\n}.
func (*JSONMessage) String ¶
func (j *JSONMessage) String() string
String returns the string presentation of your message. If there is a error decoding your message it will still return a string but will contain the error message in the form of {"Error": "message"}.
type JSONTimeStamper ¶
type JSONTimeStamper interface {
Stamp() string
}
JSONTimeStamper is used to stamp a JSON message with a time stamp of the users desire