Created
July 26, 2017 20:40
-
-
Save PumpkinSeed/620a1065bd70375ae2252d16979e8379 to your computer and use it in GitHub Desktop.
File output handler for heurelog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package output | |
import ( | |
"fmt" | |
"io/ioutil" | |
"github.com/PumpkinSeed/heurelog/config" | |
) | |
type File struct { | |
C config.Interface | |
} | |
func NewFile(cnf config.Interface) (*File, error) { | |
return &File{ | |
C: cnf, | |
}, nil | |
} | |
func (f *File) Write(message []byte) error { | |
conf := f.C.GetOutput().File | |
path := fmt.Sprintf("%s%s", conf.Location, conf.Name) | |
err := ioutil.WriteFile(path, message, 0644) | |
if err != nil { | |
return err | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment