Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Caller ¶
type Caller struct { Package string `json:"package,omitempty"` File string `json:"file,omitempty"` Line string `json:"line,omitempty"` }
Caller represents the function/method that made the log entry.
type Entry ¶
type Entry struct { // Timestamp is the time of the entry creation. Timestamp time.Time `json:"timestamp,omitempty"` // Payload is the main message to be logged. Payload interface{} `json:"payload,omitempty"` // Labels are any key-value pairs to be logged. Labels map[string]string `json:"labels,omitempty"` // Request is any request specific info to log. Request *NetworkRequest `json:"request,omitempty"` // Caller is the location in code that concerns the log entry. Caller *Caller `json:"caller,omitempty"` // Trace can be used to group similar logs together. Trace string `json:"trace,omitempty"` }
Entry is a loggable entry.
type Logger ¶
type Logger interface { // Debug logs at debug level. Debug(ctx context.Context, entry *Entry) // Info logs at info level. Info(ctx context.Context, entry *Entry) // Warn logs at warn level. Warn(ctx context.Context, entry *Entry) // Error logs at error level. Error(ctx context.Context, entry *Entry) // Fatal logs at fatal level. Fatal(ctx context.Context, entry *Entry) // Close flushes any buffered log entries. Close() error }
Logger represents a levelled and structured logger.
type NetworkRequest ¶
type NetworkRequest struct { // Protocol is the request protocol. Protocol string `json:"type,omitempty"` // ID is the identifier of the request. ID string `json:"id,omitempty"` // Status is the response code of the request. Mostly used in HTTP requests. Status int `json:"status,omitempty"` // Method is the REST verb. Method string `json:"method,omitempty"` // URL is the request's URL. URL string `json:"url,omitempty"` // RequestSize is the size of the request in bytes. RequestSize int64 `json:"request_size,omitempty"` // ResponseSize is the size of the response in bytes. ResponseSize int64 `json:"response_size,omitempty"` // Latency is time taken by the server to execute the request. Latency time.Duration `json:"latency,omitempty"` // ServerIP is the IP of the server. ServerIP string `json:"server_ip,omitempty"` // ClientIP is the IP of the client. ClientIP string `json:"client_ip,omitempty"` }
NetworkRequest is the model for the loggable data of a network request.
Click to show internal directories.
Click to hide internal directories.