Skip to content

Instantly share code, notes, and snippets.

@PumpkinSeed
Created July 26, 2017 20:40
Show Gist options
  • Save PumpkinSeed/620a1065bd70375ae2252d16979e8379 to your computer and use it in GitHub Desktop.
Save PumpkinSeed/620a1065bd70375ae2252d16979e8379 to your computer and use it in GitHub Desktop.
File output handler for heurelog
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