Documentation ¶
Overview ¶
verbose package generates formatted output only when verbose mode is turned on.
MessageType defines the header of the message and its color
- INFO: `>>info:` in cyan before the message
- TRACKER: `>>tracker:` in green before the messsage
- WARNING: `>>warning:` in orange before the messsage
- ALERT: `>>alert:` in red before the messsage
Usage ¶
verbose.Println(verbose.INFO, "everything is ok") verbose.Printf(verbose.WARNING, "value should be greater than %v", value)
Index ¶
- Variables
- func Assert(ok bool, format string, params ...interface{})
- func Debug(format string, params ...interface{})
- func Error(context string, err error) error
- func Print(msgtype MessageType, params ...interface{})
- func Printf(msgtype MessageType, format string, params ...interface{})
- func PrintfIf(ok bool, msgtype MessageType, format string, params ...interface{})
- func Println(msgtype MessageType, params ...interface{})
- func Track(start time.Time, format string, params ...interface{})
- type MessageType
Constants ¶
This section is empty.
Variables ¶
var IsDebugging bool = false
var IsOn bool = false
Set this flag to generate verbose output
Functions ¶
func Debug ¶
func Debug(format string, params ...interface{})
Debug prints a formated string to the standard stream only if versbode IsDebugging is true, otherwise does nothing.
func Error ¶
Error formats and calls Output to print to the standard stream, like Println with the messageType ALERT and only if err is not nil.
func Print ¶
func Print(msgtype MessageType, params ...interface{})
Print formats and calls Output to print to the standard stream. Arguments are handled in the manner of fmt.Print.
func Printf ¶
func Printf(msgtype MessageType, format string, params ...interface{})
Printf formats and calls Output to print to the standard stream. Arguments are handled in the manner of fmt.Printf.
func PrintfIf ¶
func PrintfIf(ok bool, msgtype MessageType, format string, params ...interface{})
PrintfIf formats and calls Output to print to the standard stream. Print out only if verbose IsOn and ok is true. Arguments are handled in the manner of fmt.Printf.
func Println ¶
func Println(msgtype MessageType, params ...interface{})
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended.
Types ¶
type MessageType ¶
type MessageType int
Type of verbose message, defines the header of the message and its color
- INFO: `>>info:` in cyan before the message
- TRACK: `>>track:` in red before the messsage
- WARNING: `>>warn:` in orange before the messsage
- ALERT: `>>alert:` in red before the messsage
const ( INFO MessageType = 0 // will output ">>info:" in cyan before the messsage WARNING MessageType = 1 // will output ">>warning:" in orange before the messsage ALERT MessageType = 2 // will output ">>alert:" in red before the messsage TRACK MessageType = 3 // will output ">>track: {timestamp}" in green before the messsage DEBUG MessageType = 4 // will output ">>debug: in yellow before the messsage )