prtty

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2015 License: MIT Imports: 5 Imported by: 3 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

prtty

GoDoc

A small go library for logging things with color.

Basics

There are five different loggers includeded out of the box:

  • Default (white)
  • Info (cyan)
  • Warn (yellow)
  • Success (green)
  • Error (red)

All the included loggers print to os.Stdout, except for Error, which prints to os.Stderr.

You can also create custom loggers with prtty.NewLogger.

The Logger type has most of the same methods as the builtin log package. In fact, it is just a lightweight wrapper around it.

prtty respects the flags set with log.SetFlags.

Usage
package main

import (
	"github.com/albrow/prtty"
)

func main() {
	// This will print to the terminal in cyan
	prtty.Info.Println("--> starting")

	// This will print in white
	prtty.Default.Println("    doing one thing...")
	prtty.Default.Println("    doing another thing...")

	// This will print in red, and just like log.Fatal, will cause the program
	// to exit with a return code of 1.
	prtty.Error.Fatal("ERROR: something went wrong :(")
}

Depending on your terminal color settings, the above program would produce output like this:

example output

License

prtty is licensed under the MIT License. See the LICENSE file for more information.

Documentation

Overview

package prtty is a small go library for logging things with color.

Index

Constants

View Source
const (
	// Color settings for the different logging functions
	// See: https://godoc.org/github.com/wsxiaoys/terminal/color
	ColorRed     = "@r"
	ColorGreen   = "@g"
	ColorBlue    = "@b"
	ColorCyan    = "@c"
	ColorMagenta = "@m"
	ColorYellow  = "@y"
	ColorBlack   = "@k"
	ColorWhite   = "@w"
)

Variables

Functions

This section is empty.

Types

type Logger

type Logger struct {
	Output io.Writer
	Color  string
}

func NewLogger

func NewLogger(out io.Writer, color string) *Logger

func (*Logger) Fatal

func (l *Logger) Fatal(v ...interface{})

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, v ...interface{})

func (*Logger) Fatalln

func (l *Logger) Fatalln(v ...interface{})

func (*Logger) Panic

func (l *Logger) Panic(v ...interface{})

func (*Logger) Panicf

func (l *Logger) Panicf(format string, v ...interface{})

func (*Logger) Panicln

func (l *Logger) Panicln(v ...interface{})

func (*Logger) Print

func (l *Logger) Print(v ...interface{})

func (*Logger) Printf

func (l *Logger) Printf(format string, v ...interface{})

func (*Logger) Println

func (l *Logger) Println(v ...interface{})

type LoggerGroup

type LoggerGroup []*Logger

func (LoggerGroup) SetColor

func (lg LoggerGroup) SetColor(color string)

func (LoggerGroup) SetOutput

func (lg LoggerGroup) SetOutput(out io.Writer)

Jump to

Keyboard shortcuts

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