Documentation ¶
Index ¶
- type Formatter
- type StreamLogger
- func (logger *StreamLogger) Name() string
- func (logger *StreamLogger) Send(message Formatter)
- func (logger *StreamLogger) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (logger *StreamLogger) ServeLogs(url string)
- func (logger *StreamLogger) Subscribe(params url.Values) chan string
- func (logger *StreamLogger) Unsubscribe(ch chan string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Formatter ¶
Formatter defines the interface that messages have to satisfy to be broadcast through StreamLogger.
type StreamLogger ¶
type StreamLogger struct {
// contains filtered or unexported fields
}
StreamLogger is a non-blocking broadcaster of messages. Subscribers can use channels or HTTP.
func New ¶
func New(name string, size int) *StreamLogger
New returns a new StreamLogger with a buffer that can contain size messages. Any messages sent to it will be available at url.
func (*StreamLogger) Name ¶
func (logger *StreamLogger) Name() string
Name returns the name of StreamLogger.
func (*StreamLogger) Send ¶
func (logger *StreamLogger) Send(message Formatter)
Send sends message to all the writers subscribed to logger. Calling Send does not block.
func (*StreamLogger) ServeHTTP ¶
func (logger *StreamLogger) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP is the http handler for StreamLogger.
func (*StreamLogger) ServeLogs ¶
func (logger *StreamLogger) ServeLogs(url string)
ServeLogs registers the URL on which messages will be broadcast. It is safe to register multiple URLs for the same StreamLogger.
func (*StreamLogger) Subscribe ¶
func (logger *StreamLogger) Subscribe(params url.Values) chan string
Subscribe returns a channel which can be used to listen for messages.
func (*StreamLogger) Unsubscribe ¶
func (logger *StreamLogger) Unsubscribe(ch chan string)
Unsubscribe removes the channel from the subscription.