logger

package module
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: MIT Imports: 8 Imported by: 0

README

go-logger

My Custom Logger. Uploaded here because I'm lazy to copypasta everywhere. image

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blue

func Blue(text any) string

Preset blue for text.

func Colorize

func Colorize(text any, atr ...color.Attribute) string

Custom styles. See: https://github.com/fatih/color

func Cyan

func Cyan(text any) string

Preset cyan for text.

func GetColorizeFunc

func GetColorizeFunc(attr ...color.Attribute) func(...any) string

func Green

func Green(text any) string

Preset green for text.

func Magenta

func Magenta(text any) string

Preset magenta for text.

func Red

func Red(text any) string

Preset red for text.

func ToTerminal

func ToTerminal(args ...any)

Print to terminal with new line at the end. Equivalent to fmt.Println.

func ToTerminalAndExit

func ToTerminalAndExit(args ...any)

Print to terminal. Exit with code 0 afterwards.

func ToTerminalAndExitFormatIfError

func ToTerminalAndExitFormatIfError(err error, format string, v ...any)

Print to termianl with format string if error (first argument) is not nil. if v is NOT passed, It'll print the format with err.

like this -> fmt.Printf(format, err)

Exit if error (first argument)

func ToTerminalAndExitIfError

func ToTerminalAndExitIfError(err error, args ...any)

Print to terminal if error (first argument) is not nil. If args (second+ arguments) is NOT passed, It'll print the error (first argument) message.

Exit if error (first argument)

func ToTerminalFormat

func ToTerminalFormat(format string, v ...any)

Print to terminal with format string. Equivalent to fmt.Printf with \n at the end.

func ToTerminalFormatAndExit

func ToTerminalFormatAndExit(format string, v ...any)

Print to terminal with format string and \n at the end. Exit with code 0 afterwards.

func ToTerminalFormatIfError

func ToTerminalFormatIfError(err error, format string, v ...any)

Print to termianl with format string if error (first argument) is not nil. if v is NOT passed, It'll print the format with err.

like this -> fmt.Printf(format, err)

func ToTerminalIfError

func ToTerminalIfError(err error, args ...any)

Print to terminal if error (first argument) is not nil. If args (second+ arguments) is NOT passed, It'll print the error (first argument) message.

func ToTerminalRed

func ToTerminalRed(args ...any)

Print to terminal with red text and new line at the end.

func ToTerminalRedAndExit

func ToTerminalRedAndExit(args ...any)

Print to terminal with red text. Exit with code 0 afterwards.

func ToTerminalRedAndExitFormatIfError

func ToTerminalRedAndExitFormatIfError(err error, format string, v ...any)

Print to termianl with format string if error (first argument) is not nil. if v is NOT passed, It'll print the format with err.

like this -> fmt.Printf(format, err)

Exit if error (first argument)

func ToTerminalRedAndExitIfError

func ToTerminalRedAndExitIfError(err error, args ...any)

Print to terminal if error (first argument) is not nil. If args (second+ arguments) is NOT passed, It'll print the error (first argument) message.

Exit if error (first argument)

func ToTerminalRedFormat

func ToTerminalRedFormat(format string, v ...any)

Print to terminal with red text formatted string and new line at the end.

func ToTerminalRedFormatAndExit

func ToTerminalRedFormatAndExit(format string, v ...any)

Print to terminal with red formatted string and \n at the end. Exit with code 0 afterwards.

func ToTerminalRedFormatIfError

func ToTerminalRedFormatIfError(err error, format string, v ...any)

Print to terminal with formatted red text if error (first argument) is not nil. If v (second+ arguments) is NOT passed, It'll print the format with err.

like this -> fmt.Printf(format, err)

func ToTerminalRedIfError

func ToTerminalRedIfError(err error, args ...any)

Print to terminal with red text if error (first argument) is not nil. If args (second+ arguments) is NOT passed, It'll print the error (first argument) message.

func ToTerminalWithoutNewLine

func ToTerminalWithoutNewLine(args ...any)

Print to terminal without new line at the end. Equivalent to fmt.Print.

func Yellow

func Yellow(text any) string

Preset yellow for text.

Types

type Logger

type Logger struct {

	// This function will be call every time Print function is call to update the prefix
	UpdatePrefix func() string
	// contains filtered or unexported fields
}

func GetDefault

func GetDefault() *Logger

func New

func New(out io.Writer, prefix string) *Logger

func (*Logger) Print

func (l *Logger) Print(v ...any)

func (*Logger) Printf

func (l *Logger) Printf(format string, v ...any)

func (*Logger) Println

func (l *Logger) Println(v ...any)

func (*Logger) SetOutput

func (l *Logger) SetOutput(w io.Writer)

func (*Logger) SetPrefix

func (l *Logger) SetPrefix(prefix string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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