utils

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package utils contains some helper functions especially for logging. Let's borrow logger package. https://github.com/rl404/go-malscraper/blob/master/pkg/mallogger/mallogger.go.

Index

Constants

View Source
const (
	// TimeFormat is timestamp format for utils.
	TimeFormat = "2006/01/02 15:04:05.000"
	// SuccessIcon is success utils indicator.
	SuccessIcon = "[S]"
	// SuccessType is key to write success utils.
	SuccessType = "success"
	// TraceIcon is trace utils indicator.
	TraceIcon = "[T]"
	// TraceType is key to write trace utils.
	TraceType = "trace"
	// DebugIcon is debug utils indicator.
	DebugIcon = "[D]"
	// DebugType is key to write debug utils.
	DebugType = "debug"
	// InfoIcon is info utils indicator.
	InfoIcon = "[I]"
	// InfoType is key to write info utils.
	InfoType = "info"
	// WarnIcon is warning utils indicator.
	WarnIcon = "[W]"
	// WarnType is key to write warn utils.
	WarnType = "warn"
	// ErrorIcon is error utils indicator.
	ErrorIcon = "[E]"
	// ErrorType is key to write error utils.
	ErrorType = "error"
	// FatalIcon is fatal error utils indicator.
	FatalIcon = "[F]"
	// FatalType is key to write fatal utils.
	FatalType = "fatal"
)
View Source
const (
	Reset         = "\033[0m"
	Red           = "\033[31m"
	Green         = "\033[32m"
	Yellow        = "\033[33m"
	Blue          = "\033[34m"
	Magenta       = "\033[35m"
	Cyan          = "\033[36m"
	White         = "\033[37m"
	BrightBlack   = "\033[90m"
	BrightRed     = "\033[91m"
	BrightGreen   = "\033[92m"
	BrightYellow  = "\033[93m"
	BrightBlue    = "\033[94m"
	BrightMagenta = "\033[95m"
	BrightCyan    = "\033[96m"
	BrightWhite   = "\033[97m"
)

Foreground text colors. The output colors may vary on different OS. Taken from https://en.wikipedia.org/wiki/ANSI_escape_code.

Variables

This section is empty.

Functions

func Debug

func Debug(text string)

Debug to write debug utils in console/terminal.

func Error

func Error(text string)

Error to write error utils in console/terminal.

func Fatal

func Fatal(text string)

Fatal to write fatal error utils in console/terminal.

func Info

func Info(text string)

Info to write info utils in console/terminal.

func Log

func Log(logType string, text string, isNeeded ...bool)

Log is helper function for easier call for all utils depends on the boolean (isNeeded). Not writing utils by default.

func LogFmt

func LogFmt(text ...string) string

LogFmt to create string with format for utils.

func Print

func Print(textColor ...string)

Print to print colored text in console/terminal.

func Println

func Println(textColor ...string)

Println to print colored text with new line in console/terminal.

func Success

func Success(text string)

Success to write success utils in console/terminal.

func Trace

func Trace(text string)

Trace to write trace utils in console/terminal.

func Warn

func Warn(text string)

Warn to write warning utils in console/terminal.

Types

This section is empty.

Jump to

Keyboard shortcuts

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