cloudflared-mirror/sshlog/manager.go

35 lines
878 B
Go
Raw Normal View History

2019-08-26 20:25:24 +00:00
package sshlog
import (
"io"
"path/filepath"
"time"
2019-08-26 20:25:24 +00:00
"github.com/cloudflare/cloudflared/logger"
2019-08-26 20:25:24 +00:00
)
// Manager be managing logs bruh
type Manager interface {
NewLogger(string, logger.Service) (io.WriteCloser, error)
NewSessionLogger(string, logger.Service) (io.WriteCloser, error)
2019-08-26 20:25:24 +00:00
}
type manager struct {
baseDirectory string
}
2019-08-26 20:25:24 +00:00
// New creates a new instance of a log manager
func New(baseDirectory string) Manager {
return &manager{
baseDirectory: baseDirectory,
}
2019-08-26 20:25:24 +00:00
}
func (m *manager) NewLogger(name string, logger logger.Service) (io.WriteCloser, error) {
return NewLogger(filepath.Join(m.baseDirectory, name), logger, time.Second, defaultFileSizeLimit)
}
func (m *manager) NewSessionLogger(name string, logger logger.Service) (io.WriteCloser, error) {
2019-09-18 19:11:12 +00:00
return NewSessionLogger(filepath.Join(m.baseDirectory, name), logger, time.Second, defaultFileSizeLimit)
2019-08-26 20:25:24 +00:00
}