22 lines
484 B
Go
Executable File
22 lines
484 B
Go
Executable File
package ripsawlogger
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path"
|
|
)
|
|
|
|
type JSONLoggerConfig struct {
|
|
Prefix string
|
|
Directory string
|
|
}
|
|
|
|
// Creates a logger that writes log data to log files on the filesystem (just uses a WriterLogger internally!).
|
|
func NewJSONLogger(cfg JSONLoggerConfig) Logger {
|
|
|
|
// create a writer to a file
|
|
writer, _ := os.OpenFile(path.Join(cfg.Directory, fmt.Sprintf("%s.json", cfg.Prefix)), os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
|
|
|
return NewWriterLogger(writer)
|
|
}
|