log

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2020 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditResponseWriter

type AuditResponseWriter struct {
	http.ResponseWriter

	URL           url.URL      // The request URL
	Identity      kes.Identity // The request X.509 identity
	RequestHeader http.Header  // The request headers
	Time          time.Time    // The time when we receive the request

	Logger *log.Logger
	// contains filtered or unexported fields
}

AuditResponseWriter is an http.ResponseWriter implementation that logs (parts of) the request and response before sending the status code back to the client.

func (*AuditResponseWriter) Flush

func (w *AuditResponseWriter) Flush()

func (*AuditResponseWriter) Header

func (w *AuditResponseWriter) Header() http.Header

func (*AuditResponseWriter) Write

func (w *AuditResponseWriter) Write(b []byte) (int, error)

func (*AuditResponseWriter) WriteHeader

func (w *AuditResponseWriter) WriteHeader(statusCode int)

type FlushWriter

type FlushWriter struct {
	io.Writer
	http.Flusher
}

A FlushWriter wraps an io.Writer and performs a flush operation after every write call if the wrapped io.Writer implements http.Flusher.

A FlushWriter is useful when (even small) data should reach the receiver as soon as possible. For example, in case of audit logging.

func NewFlushWriter

func NewFlushWriter(w io.Writer) FlushWriter

NewFlushWriter returns a new FlushWriter that wraps w and flushes everything written to it as soon as possible if w implements http.Flusher.

func (FlushWriter) Flush added in v0.7.0

func (w FlushWriter) Flush()

func (FlushWriter) Write

func (w FlushWriter) Write(p []byte) (int, error)

type JSONWriter added in v0.7.0

type JSONWriter struct {
	io.Writer
	http.Flusher
}

JSONWriter wraps an io.Writer and converts everything written to it into a JSON object object.

In particular, it converts the content passed to JSONWriter.Write into the following object:

{
  "message":"<content>"
}

Note that a JSONWriter does not try to concatinate multiple Write calls into the same JSON object. The main purpose of a JSONWriter is to convert the output of a log.Logger into JSON.

func NewJSONWriter added in v0.7.0

func NewJSONWriter(w io.Writer) JSONWriter

NewJSONWriter returns a new JSONWriter that wraps w and converts everything written to it into the following JSON object:

{
  "message":"<content"
}

func (JSONWriter) Flush added in v0.7.0

func (w JSONWriter) Flush()

func (JSONWriter) Write added in v0.7.0

func (w JSONWriter) Write(p []byte) (int, error)

func (JSONWriter) WriteString added in v0.7.0

func (w JSONWriter) WriteString(s string) (n int, err error)

type SystemLog

type SystemLog struct {
	// contains filtered or unexported fields
}

SystemLog groups a set of logging targets. It holds a reference to a *log.Logger which gets updated whenever a log target gets added or removed. Since this can happen concurrently, it is not recommended to set the log output of SystemLog.Logger() manually. Instead, modify the *log.Logger output through the SystemLog API.

func NewLogger

func NewLogger(out io.Writer, prefix string, flags int) *SystemLog

NewLogger creates a new SystemLog. The out variable sets the destination to which log data will be written. The prefix appears at the beginning of each generated log line. The flag argument defines the logging properties.

func (*SystemLog) AddOutput

func (l *SystemLog) AddOutput(out io.Writer)

AddOutput adds an output destination to the logger.

func (*SystemLog) Log

func (l *SystemLog) Log() *log.Logger

Log returns the actual logger that writes everything to the currently specified output destination.

func (*SystemLog) RemoveOutput

func (l *SystemLog) RemoveOutput(out io.Writer)

RemoveOutput removes the output destination from the logger, if it exists.

func (*SystemLog) SetOutput

func (l *SystemLog) SetOutput(out ...io.Writer)

SetOutput sets the output destination for the logger.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL