go-vitess.v1: gopkg.in/src-d/go-vitess.v1/streamlog Index | Files

package streamlog

import "gopkg.in/src-d/go-vitess.v1/streamlog"

Package streamlog provides a non-blocking message broadcaster.


Package Files



const (
    // QueryLogFormatText is the format specifier for text querylog output
    QueryLogFormatText = "text"

    // QueryLogFormatJSON is the format specifier for json querylog output
    QueryLogFormatJSON = "json"


var (
    // RedactDebugUIQueries controls whether full queries and bind variables are suppressed from debug UIs.
    RedactDebugUIQueries = flag.Bool("redact-debug-ui-queries", false, "redact full queries and bind variables from debug UI")

    // QueryLogFormat controls the format of the query log (either text or json)
    QueryLogFormat = flag.String("querylog-format", "text", "format for query logs (\"text\" or \"json\")")

    // QueryLogFilterTag contains an optional string that must be present in the query for it to be logged
    QueryLogFilterTag = flag.String("querylog-filter-tag", "", "string that must be present in the query for it to be logged")

func ShouldEmitLog Uses

func ShouldEmitLog(sql string) bool

ShouldEmitLog returns whether the log with the given SQL query should be emitted or filtered

type Formatter Uses

type Formatter interface {
    Logf(io.Writer, url.Values) error

Formatter is a simple interface for objects that expose a Format function as needed for streamlog.

type LogFormatter Uses

type LogFormatter func(out io.Writer, params url.Values, message interface{}) error

LogFormatter is the function signature used to format an arbitrary message for the given output writer.

func GetFormatter Uses

func GetFormatter(logger *StreamLogger) LogFormatter

GetFormatter returns a formatter function for objects conforming to the Formatter interface

type StreamLogger Uses

type StreamLogger struct {
    // contains filtered or unexported fields

StreamLogger is a non-blocking broadcaster of messages. Subscribers can use channels or HTTP.

func New Uses

func New(name string, size int) *StreamLogger

New returns a new StreamLogger that can stream events to subscribers. The size parameter defines the channel size for the subscribers.

func (*StreamLogger) LogToFile Uses

func (logger *StreamLogger) LogToFile(path string, logf LogFormatter) (chan interface{}, error)

LogToFile starts logging to the specified file path and will reopen the file in response to SIGUSR2.

Returns the channel used for the subscription which can be used to close it.

func (*StreamLogger) Name Uses

func (logger *StreamLogger) Name() string

Name returns the name of StreamLogger.

func (*StreamLogger) Send Uses

func (logger *StreamLogger) Send(message interface{})

Send sends message to all the writers subscribed to logger. Calling Send does not block.

func (*StreamLogger) ServeLogs Uses

func (logger *StreamLogger) ServeLogs(url string, logf LogFormatter)

ServeLogs registers the URL on which messages will be broadcast. It is safe to register multiple URLs for the same StreamLogger.

func (*StreamLogger) Subscribe Uses

func (logger *StreamLogger) Subscribe(name string) chan interface{}

Subscribe returns a channel which can be used to listen for messages.

func (*StreamLogger) Unsubscribe Uses

func (logger *StreamLogger) Unsubscribe(ch chan interface{})

Unsubscribe removes the channel from the subscription.

Package streamlog imports 13 packages (graph) and is imported by 7 packages. Updated 2019-06-13. Refresh now. Tools for package owners.