2019-09-03 21:28:06 +00:00
|
|
|
package sshlog
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
2020-04-29 20:51:32 +00:00
|
|
|
"github.com/cloudflare/cloudflared/logger"
|
2019-09-03 21:28:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
//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{}
|
|
|
|
}
|
|
|
|
|
2020-04-29 20:51:32 +00:00
|
|
|
func (m *emptyManager) NewLogger(name string, logger logger.Service) (io.WriteCloser, error) {
|
2019-09-03 21:28:06 +00:00
|
|
|
return &emptyWriteCloser{}, nil
|
|
|
|
}
|
|
|
|
|
2020-04-29 20:51:32 +00:00
|
|
|
func (m *emptyManager) NewSessionLogger(name string, logger logger.Service) (io.WriteCloser, error) {
|
2019-09-03 21:28:06 +00:00
|
|
|
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
|
|
|
|
}
|