Skip to content

Instantly share code, notes, and snippets.

@jpkotta
Created January 25, 2021 07:47
Show Gist options
  • Save jpkotta/f5c3773dafb95ee5bc089426ba8fbb4e to your computer and use it in GitHub Desktop.
Save jpkotta/f5c3773dafb95ee5bc089426ba8fbb4e to your computer and use it in GitHub Desktop.
// This buffer is for experimenting with Go code.
// Press C-c C-c to format and evaluate the buffer,
// or C-c C-p to send the buffer to the Go playground.
package main
import (
"bytes"
"encoding/binary"
"github.com/syrinsecurity/gologger"
"time"
)
func main() {
buf := new(bytes.Buffer)
logger := gologger.NewCustomLogger("/tmp/foo", ".log", 16)
logger.LineTerminator = ""
logger.ValueSeperator = ""
logger.NamingConvention = func() string {
return time.Now().Format("20060102_1504")
}
go logger.Service()
defer logger.Close()
for i := 0; i < 100; i++ {
binary.Write(buf, binary.BigEndian, uint64(time.Now().UnixNano()/1000))
binary.Write(buf, binary.BigEndian, []byte{0, 1, 2, 3, 4, 5, 6, 7})
logger.Write(buf.Bytes())
buf.Reset()
}
for {
if logger.QueueLength() == 0 {
break
}
time.Sleep(time.Millisecond * 10)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment