logtimer

package module
v0.0.0-...-86278d8 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2019 License: MIT Imports: 7 Imported by: 0

README

logtimer

Enhance your output with a timer

$ ping 8.8.8.8 | logtimer
[11:26:45] PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
[11:26:45] 64 bytes from 8.8.8.8: icmp_seq=1 ttl=123 time=16.7 ms
[11:26:46] 64 bytes from 8.8.8.8: icmp_seq=2 ttl=123 time=16.5 ms
[11:26:47] 64 bytes from 8.8.8.8: icmp_seq=3 ttl=123 time=16.1 ms
[11:26:48] 64 bytes from 8.8.8.8: icmp_seq=4 ttl=123 time=18.3 ms

Custom Format

$ ping 8.8.8.8 | logtimer --format="[%a, %d %b %Y %02H:%02M:%02S %Z] "
[Thu, 7 Feb 2019 11:27:18 CET] PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
[Thu, 7 Feb 2019 11:27:18 CET] 64 bytes from 8.8.8.8: icmp_seq=1 ttl=123 time=16.8 ms
[Thu, 7 Feb 2019 11:27:19 CET] 64 bytes from 8.8.8.8: icmp_seq=2 ttl=123 time=17.4 ms
[Thu, 7 Feb 2019 11:27:20 CET] 64 bytes from 8.8.8.8: icmp_seq=3 ttl=123 time=15.7 ms
[Thu, 7 Feb 2019 11:27:21 CET] 64 bytes from 8.8.8.8: icmp_seq=4 ttl=123 time=16.0 ms

Relative to the start

$ ping 8.8.8.8 | logtimer --relative
[00:00:00] 64 bytes from 8.8.8.8: icmp_seq=21 ttl=123 time=18.3 ms
[00:00:01] 64 bytes from 8.8.8.8: icmp_seq=21 ttl=123 time=18.3 ms
[00:00:02] 64 bytes from 8.8.8.8: icmp_seq=21 ttl=123 time=18.3 ms
...
[85:30:04] 64 bytes from 8.8.8.8: icmp_seq=22 ttl=123 time=18.5 ms

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDuration

func FormatDuration(d time.Duration, f string) string

FormatDuration formats a duration, use the follwing format: %X Total Time elapsed. (85:30:04) %Xf Total Time with Microseconds elapsed. (85:30:04.999999) %Xn Total Time with Nanoseconds elapsed. (85:30:04.999999999) %% A literal '%' character. (%)

func FormatTime

func FormatTime(t time.Time, f string) string

FormatTime formats a time, use the follwing format: %a Weekday as locale’s abbreviated name. (Sun, Mon, ..., Sat) %A Weekday as locale’s full name. (Sunday, Monday, ..., Saturday) %w Weekday as a decimal number, where 0 is Sunday and 6 is Saturday (0, 1, ..., 6) %d Day of the month as a decimal number. (1, 2, ..., 31) %b Month as locale’s abbreviated name. (Jan, Feb, ..., Dec) %B Month as locale’s full name. (January, February, ..., December) %m Month as a decimal number. (1, 2, ..., 12) %y Year without century as a decimal number. (0, 1, ..., 99) %Y Year with century as a decimal number. (1970, 1988, 2001, 2013) %H Hour (24-hour clock) as a decimal number. (0, 1, ..., 23) %I Hour (12-hour clock) as a decimal number. (1, 2, ..., 12) %p Meridian indicator. (AM, PM) %M Minute as a decimal number. (0, 1, ..., 59) %S Second as a decimal number. (0, 1, ..., 59) %f Microsecond as a decimal number. (0, 1, ..., 999999) %z UTC offset in the form +HHMM or -HHMM (+0000) %Z Time zone name (UTC) %j Day of the year as a decimal number (1, 2, ..., 366) %U Week number of the year (Sunday as the first day of the week) as a decimal number. All days in a new year preceding the first Sunday are considered to be in week 0.

(0, 1, ..., 53)

%W Week number of the year (Monday as the first day of the week) as a decimal number. All days in a new year preceding the first Monday are considered to be in week 0.

(0, 1, ..., 53)

%c Date and time representation. (Tue Aug 16 21:30:00 1988) %x Date representation. (08/16/88) %X Time representation. (21:30:00) %% A literal '%' character. (%)

Types

type ColorCorrection

type ColorCorrection int
const (
	Disabled ColorCorrection = iota
	Enabled
	Alternate
)

type FormatFunc

type FormatFunc func() string

type PrefixReader

type PrefixReader struct {
	Format FormatFunc

	ColorCorrection ColorCorrection
	io.Reader
	// contains filtered or unexported fields
}

func (*PrefixReader) Read

func (lt *PrefixReader) Read(p []byte) (int, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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