ppt

package module
v0.0.0-...-d0d0ca1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: MIT Imports: 5 Imported by: 5

README

GoPrettyPrinter

Dead simple console log colorer

This is just a test

Documentation

Overview

package ppt <-

Index

Constants

View Source
const (
	// FUNC enable function call lookup in WhereAmI()
	FUNC = lFlag(1 << iota) // enables function name to be include in log
	// LINE enable line call lookup in WhereAmI()
	LINE // enables line number to be include in log
	// FILE enable line call lookup in WhereAmI()
	FILE // enables file name to be include in log
)
View Source
const (
	// Black regular black
	Black = Colors("30")
	// Red regular red
	Red = Colors("31")
	// Green regular green
	Green = Colors("32")
	// Yellow regular yellow
	Yellow = Colors("33")
	// Blue regular blue
	Blue = Colors("34")
	// Magenta regular magenta
	Magenta = Colors("35")
	// Cyan regular cyan
	Cyan = Colors("36")
	// White regular white
	White = Colors("37")

	// Gray a brighter black
	Gray = Colors("90")
	// BRed a brighter red
	BRed = Colors("91")
	// BGreen a brighter green
	BGreen = Colors("92")
	// BYellow a brighter yellow
	BYellow = Colors("93")
	// BBlue a brighter blue
	BBlue = Colors("94")
	// BMagenta a brighter magenta
	BMagenta = Colors("95")
	// BCyan a brighter cyan
	BCyan = Colors("96")
	// BWhite a brighter white
	BWhite = Colors("97")
)

Variables

View Source
var (

	// FAT default fatal's log color foreground to red and background to yellowish
	FAT = "\033[1;31;103m"
	// ERR default error's log foreground color to regular red
	ERR = "\033[1;31m"
	// WRN default warn's log foreground color to regular yellow
	WRN = "\033[1;33m"
	// IFO default info's log foreground color to regular blue
	IFO = "\033[1;36m"
	// VER default verbose's log foreground color to regular green
	VER = "\033[1;32m"
	// TRA default trace's log foreground color to regular white
	TRA = "\033[1;37m"
)
View Source
var (
	LoggerFlags    lFlag = 0
	DisplayWarning       = true            // displaying pointer warning is on by default
	Order                = false           // changes the order of LoggerFlags prefix
	LoggerPrefix         = defaultPrefix() // goes after the log type and file|func|line info

	LogCallback = [6]func(string, ...interface{}){}
)

List of log prefixs

Functions

func Clear

func Clear()

Clear clears console

func Decorator

func Decorator(args ...string)

Decorator $log_type = [info|warn|error] $log_info = [file|func|line] $extra_prefix is developer define prefix

[0] = after log type i.e. $log_type '[' $log_info $extra_prefix $msg [1] = seperator in $log_info i.e. file '|' func '|' line [2] = after log info i.e. $log_type $log_info ']' $extra_prefix $msg

func Error

func Error(args ...interface{}) string

Error formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the string displayed to console.

func Errorf

func Errorf(msg string, args ...interface{}) string

Errorf formats according to a format specifier amoung other prefex and writes to standard output. It returns the string displayed to console.

func Errorln

func Errorln(args ...interface{}) string

Errorln formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the string displayed to console.

func Fatal

func Fatal(args ...interface{}) string

Fatal formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the string displayed to console.

func Fatalf

func Fatalf(msg string, args ...interface{}) string

Fatalf formats according to a format specifier amoung other prefex and writes to standard output. It returns the string displayed to console.

func Fatalln

func Fatalln(args ...interface{}) string

Fatalln formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the string displayed to console.

func GetColor

func GetColor(color Colors) string

GetColor return formatted ansi escape color

func GetCurrentLevel

func GetCurrentLevel() int

func Info

func Info(args ...interface{}) string

Info formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the string displayed to console.

func Infof

func Infof(msg string, args ...interface{}) string

Infof formats according to a format specifier amoung other prefex and writes to standard output. It returns the string displayed to console.

func Infoln

func Infoln(args ...interface{}) string

Infoln formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the string displayed to console.

func Init

func Init()

Init setup colors based on OS

func Printer

func Printer(prefix Log, msg string, args ...interface{}) string

Printer output msg to console with a desire log type prefix

func ResetColor

func ResetColor() string

ResetColor changes consoles' colors back to normal

func ResetCursor

func ResetCursor()

ResetCursor move cursor to the upper left corner

func SetCurrentLevel

func SetCurrentLevel(lvl Level)

func SetErrorColor

func SetErrorColor(color Colors)

SetErrorColor change the color of error log

func SetFatalColor

func SetFatalColor(color Colors)

SetFatalColor change the color of fatal log

func SetInfoColor

func SetInfoColor(color Colors)

SetInfoColor change the color of info log

func SetTraceColor

func SetTraceColor(color Colors)

SetTraceColor change the color of trace log

func SetVerboseColor

func SetVerboseColor(color Colors)

SetVerboseColor change the color of verbose log

func SetWarnColor

func SetWarnColor(color Colors)

SetWarnColor change the color of warn log

func ToBackground

func ToBackground(color Colors) string

ToBackground convert colors to background colors

func TogglePrint

func TogglePrint()

TogglePrint to console

func Trace

func Trace(args ...interface{}) string

Trace formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the string displayed to console.

func Tracef

func Tracef(msg string, args ...interface{}) string

Tracef formats according to a format specifier amoung other prefex and writes to standard output. It returns the string displayed to console.

func Traceln

func Traceln(args ...interface{}) string

Traceln formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the string displayed to console.

func Verbose

func Verbose(args ...interface{}) string

Verbose formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the string displayed to console.

func Verbosef

func Verbosef(msg string, args ...interface{}) string

Verbosef formats according to a format specifier amoung other prefex and writes to standard output. It returns the string displayed to console.

func Verboseln

func Verboseln(args ...interface{}) string

Verboseln formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the string displayed to console.

func Warn

func Warn(args ...interface{}) string

Warn formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the string displayed to console.

func Warnf

func Warnf(msg string, args ...interface{}) string

Warnf formats according to a format specifier amoung other prefex and writes to standard output. It returns the string displayed to console.

func Warnln

func Warnln(args ...interface{}) string

Warnln formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the string displayed to console.

func WhereAmI

func WhereAmI() string

WhereAmI gives the func, file or line of when the log was called func, file and line are activiated with LoggerFlags with bits FUNC, FILE, LINE

Types

type Colors

type Colors string

Colors <-

type Level

type Level uint16
const (
	FatalLevel   Level = lvlFATA
	ErrorLevel   Level = lvlFATA | lvlERRO
	WarnLevel    Level = lvlFATA | lvlERRO | lvlWARN
	InfoLevel    Level = lvlFATA | lvlERRO | lvlWARN | lvlINFO
	VerboseLevel Level = lvlFATA | lvlERRO | lvlWARN | lvlINFO | lvlVBSE
	TraceLevel   Level = lvlFATA | lvlERRO | lvlWARN | lvlINFO | lvlVBSE | lvlTRCE
)

type Log

type Log uint16

Log set custom types

Jump to

Keyboard shortcuts

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