No description
Find a file
2022-05-14 22:13:12 +05:00
.gitattributes Initial commit 2022-05-12 19:22:55 +05:00
.gitignore Initial commit 2022-05-12 19:22:55 +05:00
.travis.yml Create .travis.yml 2022-05-14 22:13:12 +05:00
defaults.go Initial commit 2022-05-12 19:22:55 +05:00
go.mod Initial commit 2022-05-12 19:22:55 +05:00
LICENSE Initial commit 2022-05-12 19:22:55 +05:00
logwriter.go Initial commit 2022-05-12 19:22:55 +05:00
logwriter_test.go Initial commit 2022-05-12 19:22:55 +05:00
README.md Fix README example format 2022-05-12 19:24:27 +05:00

logwriter

Simple Go library for SystemD's journalctl like log formatting.

Provides time prefix generation for each line of provided messages.

Usage example

import "github.com/nxshock/logwriter"

// Create new writer that writes result to stdout
writer := logwriter.New(os.Stdout)

// Set custom time format and timezone if needed
writer.TimeFormat = "02.01.06 15:04:05"
writer.TimeZone = time.UTC

writer.Print("hello world")
// result:
// 02.01.06 15:04:05 hello world

writer.Write([]byte("line 1\nline 2\nline 3"))
// result:
// 02.01.06 15:04:05 line 1
// 02.01.06 15:04:05 line 2
// 02.01.06 15:04:05 line 3

writer.Print("hello ")
writer.Print("world")
// result:
// 02.01.06 15:04:05 hello world

writer.Close()
// writes final \n if not written before