timestamper

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2022 License: MIT Imports: 4 Imported by: 1

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) transform.Transformer

New returns new timestamper

Types

type Option

type Option func(*stamper)

Option type of timestamper

func Layout

func Layout(layout string) Option

Layout for specifying custom timestamp layout

func UTC

func UTC() Option

UTC for using utc in timestamp

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL