Documentation ¶
Overview ¶
Package logging provides Logger.
Index ¶
- Constants
- func FmtSSHLog(logger Logger, s LogSessionOrContext, message string, args ...interface{})
- func GetGlobalLeakDetectorStats() (success, failure uint64)
- func ResetGlobalLeakDetectorStats()
- type LogSessionOrContext
- type Logger
- type MemoryLeakDetector
- type MemoryLeakDetectorInterface
- type MemoryLeakDetectorOff
- type MemoryLeakDetectorOn
Constants ¶
const MemoryLeakEnabled = false
MemoryLeakEnabled indicates if the memory leak detector is enabled. See LeakDetector interface.
const MemoryLeakTimeout time.Duration = time.Second
MemoryLeakTimeout is the default used by the memory detector to trigger.
Variables ¶
This section is empty.
Functions ¶
func FmtSSHLog ¶
func FmtSSHLog(logger Logger, s LogSessionOrContext, message string, args ...interface{})
FmtSSHLog formats a log message, prefixes it with information about s, and then prints it to Logger.
This message behaves like log.Printf except that it takes a Logger and LogSessionOrContext as arguments.
func GetGlobalLeakDetectorStats ¶
func GetGlobalLeakDetectorStats() (success, failure uint64)
GetGlobalLeakDetectorStats gets statistics about global leak detector calls. Blocks until a leak detector is available.
func ResetGlobalLeakDetectorStats ¶
func ResetGlobalLeakDetectorStats()
ResetGlobalLeakDetectorStats resets the stats tracker used for the global leak detector.
Types ¶
type LogSessionOrContext ¶
LogSessionOrContext represents either an ssh.Session or an ssh.Context. It is used by logging functions that accept both.
See also the github.com/gliderlabs/ssh.
type Logger ¶
type Logger interface { Print(v ...interface{}) Printf(format string, v ...interface{}) }
Logger represents an object that can be used for log messages. It is assumed to be goroutine-safe.
The log.Logger type of the builtin log package implements this type.
type MemoryLeakDetector ¶
type MemoryLeakDetector = MemoryLeakDetectorOff
MemoryLeakDetector represents the either enabled or disabled memory leak detector. See MemoryLeakDetectorInterface for documentation.
func NewLeakDetector ¶
func NewLeakDetector() MemoryLeakDetector
NewLeakDetector creates a new MemoryLeakDetector object.
type MemoryLeakDetectorInterface ¶
type MemoryLeakDetectorInterface interface { // Add and Done are used to register async processes with this LeakDetector. // // A call to Add() should be performed when an async action is started. // A call to Done() with the same name should be performed when the async action is completed as expected. // // Names should be unique. Upon reuse, Add() and Done() call panic(). Add(name string) Done(name string) // Finish checks if all calls to Add() have been undone by a call to Done(). // It should be called syncronously. // // If this is not the case within MemoryLeakTimeout, it prints to logger an appropriate error message. // If this is the case, it prints a short message confirming that the leak check completed. Finish(logger Logger, s LogSessionOrContext) }
MemoryLeakDetectorInterface represents a Memory Leak Detector. It is used to ensure that no concurrent processes have caused a memory leak within sessions.
This interface is not used at runtime, it serves only for documentation purposes. The MemoryLeakDetectorInterface can be turned on or off at build time using the "leak" build tag. This sets the MemoryLeakDetector type alias is set either to MemoryLeakDetectorOn or MemoryLeakDetectorOff. These contain the actual implementation.
At runtime, all instances should be created using NewLeakDetector and never MemoryLeakDetectorOn or MemoryLeakDetectorOff. They are still exposed, so that both implementations can be tested.
When the MemoryLeakDetectorInterface is disabled, all functions in this interface are noops. As opposed to using this interface, that enables the disabled variant to be compiled away.
type MemoryLeakDetectorOff ¶
type MemoryLeakDetectorOff struct{}
MemoryLeakDetectorOff is the disabled variant of MemoryLeakDetectorInterface.
func (MemoryLeakDetectorOff) Add ¶
func (d MemoryLeakDetectorOff) Add(name string)
Add implements MemoryLeakDetectorInterface.Add.
func (MemoryLeakDetectorOff) Done ¶
func (d MemoryLeakDetectorOff) Done(name string)
Done implements MemoryLeakDetectorInterface.Done.
func (MemoryLeakDetectorOff) Finish ¶
func (d MemoryLeakDetectorOff) Finish(logger Logger, s LogSessionOrContext)
Finish implements MemoryLeakDetectorInterface.Finish.
type MemoryLeakDetectorOn ¶
type MemoryLeakDetectorOn struct {
// contains filtered or unexported fields
}
MemoryLeakDetectorOn is the enabled variant of MemoryLeakDetectorInterface.
func (*MemoryLeakDetectorOn) Add ¶
func (d *MemoryLeakDetectorOn) Add(name string)
Add implements MemoryLeakDetectorInterface.Add.
func (*MemoryLeakDetectorOn) Done ¶
func (d *MemoryLeakDetectorOn) Done(name string)
Done implements MemoryLeakDetectorInterface.Done.
func (*MemoryLeakDetectorOn) Finish ¶
func (d *MemoryLeakDetectorOn) Finish(logger Logger, s LogSessionOrContext)
Finish implements MemoryLeakDetectorInterface.Finish.