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