Documentation ¶
Overview ¶
Package streamlog provides a non-blocking message broadcaster.
Index ¶
- Constants
- func GetQueryLogFilterTag() string
- func GetQueryLogFormat() string
- func GetQueryLogRowThreshold() uint64
- func GetRedactDebugUIQueries() bool
- func SetQueryLogFilterTag(newQueryLogFilterTag string)
- func SetQueryLogFormat(newQueryLogFormat string)
- func SetQueryLogRowThreshold(newQueryLogRowThreshold uint64)
- func SetRedactDebugUIQueries(newRedactDebugUIQueries bool)
- func ShouldEmitLog(sql string, rowsAffected, rowsReturned uint64) bool
- type Formatter
- type LogFormatter
- type StreamLogger
- func (logger *StreamLogger) LogToFile(path string, logf LogFormatter) (chan any, error)
- func (logger *StreamLogger) Name() string
- func (logger *StreamLogger) Send(message any)
- func (logger *StreamLogger) ServeLogs(url string, logf LogFormatter)
- func (logger *StreamLogger) Subscribe(name string) chan any
- func (logger *StreamLogger) Unsubscribe(ch chan any)
Constants ¶
const ( // QueryLogFormatText is the format specifier for text querylog output QueryLogFormatText = "text" // QueryLogFormatJSON is the format specifier for json querylog output QueryLogFormatJSON = "json" )
Variables ¶
This section is empty.
Functions ¶
func GetQueryLogFilterTag ¶ added in v0.15.0
func GetQueryLogFilterTag() string
func GetQueryLogFormat ¶ added in v0.15.0
func GetQueryLogFormat() string
func GetQueryLogRowThreshold ¶ added in v0.15.0
func GetQueryLogRowThreshold() uint64
func GetRedactDebugUIQueries ¶ added in v0.15.0
func GetRedactDebugUIQueries() bool
func SetQueryLogFilterTag ¶ added in v0.15.0
func SetQueryLogFilterTag(newQueryLogFilterTag string)
func SetQueryLogFormat ¶ added in v0.15.0
func SetQueryLogFormat(newQueryLogFormat string)
func SetQueryLogRowThreshold ¶ added in v0.15.0
func SetQueryLogRowThreshold(newQueryLogRowThreshold uint64)
func SetRedactDebugUIQueries ¶ added in v0.15.0
func SetRedactDebugUIQueries(newRedactDebugUIQueries bool)
func ShouldEmitLog ¶
ShouldEmitLog returns whether the log with the given SQL query should be emitted or filtered
Types ¶
type Formatter ¶
Formatter is a simple interface for objects that expose a Format function as needed for streamlog.
type LogFormatter ¶
LogFormatter is the function signature used to format an arbitrary message for the given output writer.
func GetFormatter ¶
func GetFormatter(logger *StreamLogger) LogFormatter
GetFormatter returns a formatter function for objects conforming to the Formatter interface
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 that can stream events to subscribers. The size parameter defines the channel size for the subscribers.
func (*StreamLogger) LogToFile ¶
func (logger *StreamLogger) LogToFile(path string, logf LogFormatter) (chan any, 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 ¶
func (logger *StreamLogger) Name() string
Name returns the name of StreamLogger.
func (*StreamLogger) Send ¶
func (logger *StreamLogger) Send(message any)
Send sends message to all the writers subscribed to logger. Calling Send does not block.
func (*StreamLogger) ServeLogs ¶
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 ¶
func (logger *StreamLogger) Subscribe(name string) chan any
Subscribe returns a channel which can be used to listen for messages.
func (*StreamLogger) Unsubscribe ¶
func (logger *StreamLogger) Unsubscribe(ch chan any)
Unsubscribe removes the channel from the subscription.