TaskLog is a task-based logger for Go (golang) with a simple API interface.
It's intended to be used by humans, as it uses ansi escape codes to format the output, making it easy to read in a terminal.
go get -u github.com/mrmarble/tasklogFor simple logging, import the global logger package github.com/mrmarble/tasklog/log
package main
import "github.com/mrmarble/tasklog/log"
func main() {
log.Task("Doing some work")
log.Task("Another task")
log.Skip("some reason")
}
// Output: [✓] Doing some work
// [→] Another task (some reason)Note: By default log writes to os.Stderr
You can also log additional information by using the Printmethods
package main
import "github.com/mrmarble/tasklog/log"
func main() {
log.Task("Doing some work")
log.Print("This is some additional information")
}
// Output: [✓] Doing some work
// This is some additional informationBy default, the additional information is deleted when a new task is started. You can change this behavior by using a custom logger.
You can customize the logger by using the corresponding Setmethods.
package main
import (
"os"
"github.com/charmbracelet/x/ansi"
"github.com/mrmarble/tasklog"
)
func main() {
log := tasklog.New(os.Stdout)
log.SetPersistent(true) // Keep the additional information when a new task is started
log.SetProgressColor(ansi.HexColor("#88AAFF")). // Supports any color implementing color.Color interface
log.Task("Doing some work")
}
// Output: [ ] Doing some workI welcome any contributions. Just create a PR or an issue.

