Documentation
¶
Index ¶
- type CounterMetric
- type CustomLogger
- func (l *CustomLogger) LogDebug(str string)
- func (l *CustomLogger) LogDebugf(str string, args ...interface{})
- func (l *CustomLogger) LogError(str string, err error)
- func (l *CustomLogger) LogErrorInterface(v ...interface{})
- func (l *CustomLogger) LogErrorMessage(str string, err error, pairs ...Pair)
- func (l *CustomLogger) LogErrorWithoutError(str string)
- func (l *CustomLogger) LogErrorWithoutErrorf(str string, args ...interface{})
- func (l *CustomLogger) LogInfo(str string)
- func (l *CustomLogger) LogInfoMessage(str string, pairs ...Pair)
- func (l *CustomLogger) LogInfof(str string, args ...interface{})
- func (l *CustomLogger) LogMessage(message string)
- func (l *CustomLogger) LogMessagef(message string, args ...interface{})
- func (l *CustomLogger) LogWarning(str string)
- func (l *CustomLogger) LogWarningMessage(str string, pairs ...Pair)
- func (l *CustomLogger) LogWarningf(str string, args ...interface{})
- func (l *CustomLogger) Tic(s string) (string, time.Time)
- func (l *CustomLogger) Toc(message string, startTime time.Time)
- type HistogramMetric
- type IMetricVec
- type IMultiLogger
- type LogLevels
- type Option
- type Pair
- type RateLatencyLogger
- type RateLatencyOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CounterMetric ¶
type CounterMetric struct {
// contains filtered or unexported fields
}
CounterMetric : Default histogram message type implementing IMetricVec
func NewCounterMetric ¶
func NewCounterMetric(hist *prometheus.CounterVec, logger *CustomLogger) *CounterMetric
NewCounterMetric creates a new histrogram message and registers it to prometheus
func (*CounterMetric) RemoveLogging ¶
func (msg *CounterMetric) RemoveLogging(labels ...string)
RemoveLogging will stop logging for specific labels
func (*CounterMetric) Update ¶
func (msg *CounterMetric) Update(elapsed int64, labels ...string)
Update the message with calculated latency
type CustomLogger ¶
type CustomLogger struct {
// contains filtered or unexported fields
}
CustomLogger is a graylog logger for golang
func NewLogger ¶
func NewLogger(LoggerOptions ...Option) *CustomLogger
NewLogger : returns a new logger. When no options are given, it returns an error logger With graylog logging as default to a port 11100 which is not in use. So it is prety much useless. Please provide graylog host and port at the very least.
func (*CustomLogger) LogDebug ¶
func (l *CustomLogger) LogDebug(str string)
LogDebug is used to send debug messages
func (*CustomLogger) LogDebugf ¶
func (l *CustomLogger) LogDebugf(str string, args ...interface{})
LogDebugf is used to send debug messages
func (*CustomLogger) LogError ¶
func (l *CustomLogger) LogError(str string, err error)
LogError is used to send errors and a message along with the error
func (*CustomLogger) LogErrorInterface ¶
func (l *CustomLogger) LogErrorInterface(v ...interface{})
LogErrorInterface is used to send errors
func (*CustomLogger) LogErrorMessage ¶
func (l *CustomLogger) LogErrorMessage(str string, err error, pairs ...Pair)
LogErrorMessage is used to send extra fields to graylog along with the error
func (*CustomLogger) LogErrorWithoutError ¶
func (l *CustomLogger) LogErrorWithoutError(str string)
LogErrorWithoutError is used to send only a message and not an error
func (*CustomLogger) LogErrorWithoutErrorf ¶
func (l *CustomLogger) LogErrorWithoutErrorf(str string, args ...interface{})
LogErrorWithoutErrorf is used to send only a message and not an error
func (*CustomLogger) LogInfo ¶
func (l *CustomLogger) LogInfo(str string)
LogInfo is used to send info messages
func (*CustomLogger) LogInfoMessage ¶
func (l *CustomLogger) LogInfoMessage(str string, pairs ...Pair)
LogInfoMessage is used to send extra fields to graylog
func (*CustomLogger) LogInfof ¶
func (l *CustomLogger) LogInfof(str string, args ...interface{})
LogInfof is used to send formatted info messages
func (*CustomLogger) LogMessage ¶
func (l *CustomLogger) LogMessage(message string)
LogMessage is used to log plain message
func (*CustomLogger) LogMessagef ¶
func (l *CustomLogger) LogMessagef(message string, args ...interface{})
LogMessagef is used to log plain message
func (*CustomLogger) LogWarning ¶
func (l *CustomLogger) LogWarning(str string)
LogWarning is used to send warning messages
func (*CustomLogger) LogWarningMessage ¶
func (l *CustomLogger) LogWarningMessage(str string, pairs ...Pair)
LogWarningMessage is used to send warning messages along with extra fields to GrayLog
func (*CustomLogger) LogWarningf ¶
func (l *CustomLogger) LogWarningf(str string, args ...interface{})
LogWarningf is used to send warning messages
func (*CustomLogger) Tic ¶
func (l *CustomLogger) Tic(s string) (string, time.Time)
Tic is used to log time taken by a function. It should be used along with Toc function Tic will take an input as a string message (It can be the name of the function) And will return time and the message. For full used see the Toc funtion
func (*CustomLogger) Toc ¶
func (l *CustomLogger) Toc(message string, startTime time.Time)
Toc will log the time taken by the funtion. Its input is the output of the Tic function Here is an example code block for using Tic and Toc function
defer Toc(Tic("FunctionName"))
This will the first line of the function
type HistogramMetric ¶
type HistogramMetric struct {
// contains filtered or unexported fields
}
HistogramMetric : Default histogram message type implementing IMetricVec
func NewHistogramMetric ¶
func NewHistogramMetric(hist *prometheus.HistogramVec, logger *CustomLogger) *HistogramMetric
NewHistogramMetric creates a new histrogram message and registers it to prometheus
func (*HistogramMetric) RemoveLogging ¶
func (msg *HistogramMetric) RemoveLogging(labels ...string)
RemoveLogging will stop logging for specific labels
func (*HistogramMetric) Update ¶
func (msg *HistogramMetric) Update(elapsed int64, labels ...string)
Update the message with calculated latency
type IMetricVec ¶
type IMetricVec interface { Update(int64, ...string) // Method to Reset the message struct RemoveLogging(...string) }
IMetricVec : Interface to implement for Message type
type IMultiLogger ¶
type IMultiLogger interface { // To measure time elapsed between any two points in the code, // Start the time logger by Tic(MessageDesc) and end the time logger by calling Toc(MessageDesc,time) Tic() time.Time Toc(time.Time, string, ...string) // Starts the logger in a go routine Run() AddNewMetric(string, IMetricVec) }
IMultiLogger : Interface for Multi message logger
func NewRateLatencyLogger ¶
func NewRateLatencyLogger(options ...RateLatencyOption) IMultiLogger
NewRateLatencyLogger : returns a new RateLatencyLogger. When no options are given, it returns a RateLatencyLogger with default settings. Default logger is default custom logger.
type LogLevels ¶
type LogLevels uint32
LogLevels are the log levels for logging
const ( // ERROR : All errors will be logged with this level ERROR LogLevels = 0 // WARN : All important events should be logged with a warn WARN LogLevels = 1 // INFO : All events other than the important ones to be logged here INFO LogLevels = 2 // DEBUG : This is for debug purposes only. Never use it on staging and production DEBUG LogLevels = 3 )
type Option ¶
type Option func(l *CustomLogger)
Option sets a parameter for the Logger
func ConsolePrintEnabled ¶
ConsolePrintEnabled enables console output for logging. To be used only for development.
func DisableGraylog ¶
DisableGraylog disables graylog logging. Defaults to false If graylog is disabled console logging will be enabled by default
func GraylogFacility ¶
GraylogFacility sets the graylog facility for the logger. Default is "ErrorLogger"
func GraylogHost ¶
GraylogHost sets the graylog host for the logger. Default is 127.0.0.1
func GraylogPort ¶
GraylogPort sets the graylog port for the logger. Default is 11100
func SetLogLevel ¶
SetLogLevel sets the logger level Possible values are ERROR, WARN, INFO, DEBUG. Default is ERROR
func TimeLoggingEnabled ¶
TimeLoggingEnabled enables logging of time (The use of tic toc functions). This can be used in functions and then disabled here when there is no need.
type RateLatencyLogger ¶
type RateLatencyLogger struct {
// contains filtered or unexported fields
}
RateLatencyLogger : Logger that tracks multiple messages & prints to console
func (*RateLatencyLogger) AddNewMetric ¶
func (mgl *RateLatencyLogger) AddNewMetric(messageIdentifier string, newMessage IMetricVec)
AddNewMetric sets New message initialisation function
func (*RateLatencyLogger) Run ¶
func (mgl *RateLatencyLogger) Run()
Run : Starts the logger in a go routine. Calling this multiple times doesn't have any effect
type RateLatencyOption ¶
type RateLatencyOption func(rl *RateLatencyLogger)
RateLatencyOption sets a parameter for the RateLatencyLogger
func SetLogger ¶
func SetLogger(logger *CustomLogger) RateLatencyOption
SetLogger sets the output logger. Default is stderr