2019-09-03 21:28:06 +00:00
|
|
|
package sshlog
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
//empty manager implements the Manager but does nothing (for testing and to disable logging unless the logs are set)
|
|
|
|
type emptyManager struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
type emptyWriteCloser struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewEmptyManager creates a new instance of a log empty log manager that does nothing
|
|
|
|
func NewEmptyManager() Manager {
|
|
|
|
return &emptyManager{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *emptyManager) NewLogger(name string, logger *logrus.Logger) (io.WriteCloser, error) {
|
|
|
|
return &emptyWriteCloser{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *emptyManager) NewSessionLogger(name string, logger *logrus.Logger) (io.WriteCloser, error) {
|
|
|
|
return &emptyWriteCloser{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// emptyWriteCloser
|
|
|
|
|
|
|
|
func (w *emptyWriteCloser) Write(p []byte) (n int, err error) {
|
2019-09-10 23:50:04 +00:00
|
|
|
return len(p), nil
|
2019-09-03 21:28:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (w *emptyWriteCloser) Close() error {
|
|
|
|
return nil
|
|
|
|
}
|