Categorygithub.com/Songmu/timestamper
repositorypackage
0.1.0
Repository: https://github.com/songmu/timestamper.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

timestamper

Build Status Coverage Status MIT License GoDoc

text transformer to put timestamps. It is very useful for logging.

Description

The text transformer to put timestamps. The timestamper implements golang.org/x/text/transform.Transform interface.

Synopsis

Easy Usage

var s transform.Transformer = timestamper.New()
var w io.WriteCloser = transform.NewWriter(os.Stdout, s)
fmt.Fprint(w, "Hello\nWorld!")
// Output:
// 2019-02-11T01:14:54.093021+09:00 Hello
// 2019-02-11T01:14:54.093151+09:00 World!

Functional Option

s1 := timestamper.New(timestamper.UTC()) // use UTC timestamp
s2 := timestamper.New(timestamper.Layout("06-01-02 15:04:05 ")) // specify custom layout

Installation

% go get github.com/Songmu/timestamper
% go install github.com/Songmu/timestamper/cmd/timestamp

Usage

How to use the included command line tool called timestamp.

% tail -f path/to/log | timestamp
...log with timestamp here...

Author

Songmu