common

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package common provides constants and utility functions that are shared across the poa packages

Index

Constants

View Source
const (
	ColourInfo    = color.FgGreen
	ColourWarning = color.FgHiMagenta
	ColourError   = color.FgHiRed
	ColourPrompt  = color.FgHiYellow
	ColourOther   = color.FgYellow
	ColourOutput  = color.FgHiCyan
	ColourDebug   = color.FgCyan
)

Colour definitions as used in the Message functions in this unit.

View Source
const (
	MsgInformation = 0
	MsgWarning     = 1
	MsgError       = 2
	MsgPrompt      = 3
	MsgDebug       = 4
	MsgOther       = 5
)

Log level constants

Variables

View Source
var MonikerRegexp = regexp.MustCompile("^[a-zA-Z0-9_]*$")

MonikerRegexp defines the set of characters that monikers can be composed of.

View Source
var (
	// VerboseLogging is a globals that controls debug message output. It is
	// Controlled by the --verbose option in monetd.
	VerboseLogging bool
)

Functions

func CheckIP added in v0.3.0

func CheckIP(ip string, portOnlyOk bool) bool

CheckIP tests whether an IP address is on a subnet

func CheckMoniker added in v0.2.0

func CheckMoniker(moniker string) bool

CheckMoniker verifies if the moniker matches the MonikerRegexp.

func ClearScreen

func ClearScreen()

ClearScreen clears the CLI screen. Implementation is OS-specific

func DebugMessage added in v0.2.0

func DebugMessage(a ...interface{}) (n int, err error)

DebugMessage is a simple wrapper for stdout logging. Setting VerboseLayout to false disables its output

func DefaultLogger added in v0.2.0

func DefaultLogger() *logrus.Logger

DefaultLogger returns a default logger instance

func ErrorMessage added in v0.2.0

func ErrorMessage(a ...interface{}) (n int, err error)

ErrorMessage is a simple wrapper for stdout logging for Error Messages.

func GetMyIP

func GetMyIP() string

GetMyIP returns the IP address of this instance as a string.

func InfoMessage added in v0.2.0

func InfoMessage(a ...interface{}) (n int, err error)

InfoMessage is a simple wrapper for stdout logging of Information Messages

func LogLevel added in v0.2.0

func LogLevel(l string) logrus.Level

LogLevel converts a string to a logrus logging level constant

func MessageWithType

func MessageWithType(msgType int, a ...interface{}) (n int, err error)

MessageWithType is a central point for cli logging messages It colour codes the output, suppressing Debug messages if VerboseLogging is false

func MustPrintJSON added in v0.2.0

func MustPrintJSON(jsonObject interface{}) error

MustPrintJSON prints the JSON encoding of the given object and exits the program with an error message when the marshaling fails.

func PromptMessage added in v0.3.0

func PromptMessage(a ...interface{}) (n int, err error)

PromptMessage displays a prompt message in the appropriate color.

Types

This section is empty.

Jump to

Keyboard shortcuts

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