Package prefixwriter provides a writer that prefixes each line with a specified byte slice.
Important
Deprecated: Use github.com/goaux/decowriter instead
- Adds a specified prefix to the beginning of each line
- Implements the
io.Writer
interface - Customizable buffer size
- Tracks total bytes written
package main
import (
"fmt"
"os"
"github.com/goaux/prefixwriter"
)
func main() {
w := prefixwriter.New(os.Stdout, []byte("LOG: "))
fmt.Fprintln(w, "This is a log message")
fmt.Fprintln(w, "Another log message")
}
OUTPUT:
LOG: This is a log message
LOG: Another log message