28 lines
577 B
Go
28 lines
577 B
Go
package logger
|
|
|
|
import (
|
|
"io"
|
|
"log/slog"
|
|
"os"
|
|
"sync"
|
|
)
|
|
|
|
type fileRouter struct {
|
|
mu sync.RWMutex
|
|
handlers map[string]slog.Handler // map[filePath]handler
|
|
files map[string]*os.File // map[filePath]*os.File to close later
|
|
baseDir string
|
|
rotationDays int
|
|
id string
|
|
dirTimeLayout string // "2006-01-02" - daily dirs
|
|
}
|
|
|
|
// prefixWriter - writes a prefix at the start of each new line.
|
|
// It is safe for concurrent use.
|
|
type prefixWriter struct {
|
|
inner io.Writer
|
|
prefix []byte
|
|
mu sync.Mutex
|
|
startLine bool
|
|
}
|