package logger
import "github.com/Azure/azure-sdk-for-go/sdk/internal/logger"
Index ¶
- type Listener
- type LogClassification
- type Logger
- func Log() *Logger
- func (l *Logger) SetClassifications(cls ...LogClassification)
- func (l *Logger) SetListener(lst Listener)
- func (l *Logger) Should(cls LogClassification) bool
- func (l *Logger) Write(cls LogClassification, message string)
- func (l *Logger) Writef(cls LogClassification, format string, a ...interface{})
Types ¶
type Listener ¶
type Listener func(LogClassification, string)
Listener is the funciton signature invoked when writing log entries. A Listener is required to perform its own synchronization if it's expected to be called from multiple Go routines
type LogClassification ¶
type LogClassification string
LogClassification is used to group entries. Each group can be toggled on or off
const ( // LogRequest entries contain information about HTTP requests. // This includes information like the URL, query parameters, and headers. LogRequest LogClassification = "Request" // LogResponse entries containe information about HTTP responses. // This includes information like the HTTP status code, headers, and request URL. LogResponse LogClassification = "Response" // LogRetryPolicy entries contain information specific to the rety policy in use. LogRetryPolicy LogClassification = "RetryPolicy" // LogLongRunningOperation entries contian information specific to long-running operations. // This includes information like polling location, operation state, and sleep intervals. LogLongRunningOperation LogClassification = "LongRunningOperation" )
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger controls which classifications to log and writing to the underlying log.
func Log ¶
func Log() *Logger
Log returns the process-wide logger.
func (*Logger) SetClassifications ¶
func (l *Logger) SetClassifications(cls ...LogClassification)
SetClassifications is used to control which classifications are written to the log. By default all log classifications are writen.
func (*Logger) SetListener ¶
SetListener will set the Logger to write to the specified Listener.
func (*Logger) Should ¶
func (l *Logger) Should(cls LogClassification) bool
Should returns true if the specified log classification should be written to the log. By default all log classifications will be logged. Call SetClassification() to limit the log classifications for logging. If no listener has been set this will return false. Calling this method is useful when the message to log is computationally expensive and you want to avoid the overhead if its log classification is not enabled.
func (*Logger) Write ¶
func (l *Logger) Write(cls LogClassification, message string)
Write invokes the underlying Listener with the specified classification and message. If the classification shouldn't be logged or there is no listener then Write does nothing.
func (*Logger) Writef ¶
func (l *Logger) Writef(cls LogClassification, format string, a ...interface{})
Writef invokes the underlying Listener with the specified classification and formatted message. If the classification shouldn't be logged or there is no listener then Writef does nothing.
Source Files ¶
- Version
- v0.5.2
- Published
- Jul 28, 2021
- Platform
- js/wasm
- Imports
- 3 packages
- Last checked
- 52 minutes ago –
Tools for package owners.