A Go library for logging to interactive terminals
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
_demo Optimize screenshot Nov 19, 2015
vendor dep update Nov 16, 2017
.appveyor.yml Appveyor & Travis Feb 10, 2016
.gitignore Initial checkin Nov 19, 2015
.travis.yml travis: use go 1.9 Nov 1, 2017
Gopkg.lock dep update Nov 16, 2017
Gopkg.toml dep update Nov 16, 2017
LICENSE README tweaks, LICENSE Nov 19, 2015
README.md Build badges Feb 10, 2016
context.go Add Streams Jan 6, 2016
group.go Add Streams Jan 6, 2016
stream.go LogTest - convenient access to logs from test suites Feb 10, 2016
termlog.go Default "dumb" terminals to no color Mar 18, 2016
termlog_test.go Add Streams Jan 6, 2016
testing.go LogTest - convenient access to logs from test suites Feb 10, 2016


GoDoc Travis Build Status Build status

termlog: Logging for interactive terminals


Basic usage

l := termlog.NewLog()

Each log entry gets a timestamp.


Groups collect entries together under a single timestamp, with subsequent lines indented:

g = l.Group()
g.Say("This line gets a timestamp")
g.Say("This line will be indented with no timestamp")

Groups produce no output until the .Done() method is called - a good use for defer. Termlog ensures that all grouped entries appear together in output.


Streams associate log entries with a header. New stream log entries only get a header if another log source (i.e. a different stream, group, or plain log) has produced output in the meantime. Each stream log entry gets its own timestamp.

g = l.Stream("This is the header")
g.Say("The header will be printed before this line")
g.Say("But not before this one")

Named logs

Log entries can be named using the *As methods:

l := termlog.NewLog()
l.SayAs("debug", "Some debugging info")

Named entries are always silenced, unless they've been enabled specifically, like so:


Specified colors

The package is compatible with the color specifications from github.com/fatih/color, which means that colors can be composed like this:

l.Say("Here are some composed colors...")
	"%s %s %s",