Skip to content

mh-cbon/verbose

Repository files navigation

Verbose

A library to display verbose messages per package.

Read the doc at godoc

demo

Install

glide get github.com/mh-cbon/verbose

Usage

package main

import (
  "github.com/mh-cbon/verbose"
)

var logger = verbose.Auto()

func main () {
  logger.Println("something you want to tell about...")
}

Command line

to display the log messages from your binary you will have to set VERBOSE env variable,

VERBOSE=package goprogram

Where VERBOSE is a comma separated list of package patterns to display,

VERBOSE=package*,package2 goprogram

when VERBOSE=* all log messages will display

VERBOSE=* goprogram

Configuring the printer

Using verbose.SetPrinter(p printer.Printer) you can define the printer at runtime.

To avoid collision, its preferable to configure it into main

The default printer is LogPrinter a wrapper of go/log package.

package main

import (
  "fmt"
  "github.com/mh-cbon/verbose"
  "github.com/mh-cbon/verbose/printer"
  "test"
)

var logger = verbose.Auto()

func main () {

  verbose.SetPrinter(printer.FmtPrinter{}) // changed to a wrapper of go/fmt

  fmt.Println("Hello from main")
  logger.Println("message to log from main github.com/mh-cbon/verbose")
  a.Hello()
}

printer.Printer interface

type Printer interface {
	Printf(logger *Logger, format string, a ...interface{})
	Print(logger *Logger, v ...interface{})
	Println(logger *Logger, v ...interface{})
}

About

Go verbose messages

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages