pp

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package pp handles pretty-printing.

Index

Constants

View Source
const (
	Debug        Level = iota // debugging info, currently not used
	Info                      // additional information that is not an action, a warning, or an error
	Notice                    // an action (e.g., changing the IP) has happened and it is not an error
	Warning                   // non-fatal errors where the updater should continue updating IP addresses
	Error                     // fatal errors where the updater should stop
	DefaultLevel = Info
	Verbose      = Info
	Quiet        = Notice
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Emoji

type Emoji string

Emoji is the type of emoji strings.

const (
	EmojiStar   Emoji = "🌟" // stars attached to the tool name
	EmojiBullet Emoji = "🔸" // generic bullet points

	EmojiEnvVars      Emoji = "📖" // reading configuration
	EmojiConfig       Emoji = "🔧" // showing configuration
	EmojiInternet     Emoji = "🌐" // network address detection
	EmojiPrivileges   Emoji = "🥷" // /privileges
	EmojiMute         Emoji = "🔇" // quiet mode
	EmojiExperimental Emoji = "🧪" // experimental features

	EmojiCreateRecord Emoji = "🐣" // adding new DNS records
	EmojiDeleteRecord Emoji = "💀" // deleting DNS records
	EmojiUpdateRecord Emoji = "📡" // updating DNS records
	EmojiClearRecord  Emoji = "🧹" // clearing DNS records

	EmojiNotification Emoji = "🔔" // sending out notifications, pinging, health checks
	EmojiRepeat       Emoji = "🔁" // repeating things

	EmojiSignal      Emoji = "🚨" // catching signals
	EmojiAlreadyDone Emoji = "🤷" // DNS records were already up to date
	EmojiNow         Emoji = "🏃" // an event that is happening now or immediately
	EmojiAlarm       Emoji = "⏰" // an event that is scheduled to happen, but not immediately
	EmojiBye         Emoji = "👋" // bye!

	EmojiGood        Emoji = "😊" // good news
	EmojiUserError   Emoji = "😡" // configuration mistakes made by users
	EmojiUserWarning Emoji = "😦" // warnings about possible configuration mistakes
	EmojiError       Emoji = "😞" // errors that are not (directly) caused by user errors
	EmojiWarning     Emoji = "😐" // warnings about something unusual
	EmojiImpossible  Emoji = "🤯" // the impossible happened
)

type Level

type Level int

Level is the type of message levels.

type PP

type PP interface {
	// SetEmoji sets whether emojis should be used.
	SetEmoji(emoji bool) PP

	// SetLevel sets the level under which messages will be hidden.
	SetLevel(level Level) PP

	// IsEnabledFor checks whether a message of a certain level will be displayed.
	IsEnabledFor(level Level) bool

	// IncIndent returns a new pretty-printer with more indentation.
	IncIndent() PP

	// Infof formats and prints a message at the info level.
	Infof(emoji Emoji, format string, args ...any)

	// Noticef formats and prints a message at the notice level.
	Noticef(emoji Emoji, format string, args ...any)

	// Warningf formats and prints a message at the warning level.
	Warningf(emoji Emoji, format string, args ...any)

	// Errorf formats and prints a message at the error level.
	Errorf(emoji Emoji, format string, args ...any)
}

PP is the abstraction of a pretty printer.

func New

func New(writer io.Writer) PP

New creates a new pretty printer.

Jump to

Keyboard shortcuts

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