info

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package info is a simple logger that displays detailed information when the "--verbose" flag is set.

Index

Examples

Constants

This section is empty.

Variables

View Source
var Prefix = "[LOG]: "

Prefix is the prefix of each record in the log.

Functions

func Clear

func Clear()

Clear clears the current log.

func Get

func Get() string

Get returns the current log.

func Log

func Log(logs ...string) (int, error)

Log writes the given logs to the log buffer.

Note that if a "logs" is empty, or all blank, nothing is recorded.

Example
// To avoid conflicts during testing this example, back up the current buffer
// and restore it later. This is usually not necessary.
oldLogBuff := logBuff
defer func() {
	logBuff = oldLogBuff
}()

/* Example usage */

// Log
if _, err := Log("This", "is", "the", "log1"); err != nil {
	log.Println(err)

	return
}

// Logging
if _, err := Log("This", "is", "the", "log2"); err != nil {
	log.Println(err)

	return
}

// Get the current log.
fmt.Println("Log output:")
fmt.Println(Get())

// Clear the log.
Clear()

// After calling `Clear()` the log becomes empty.
fmt.Printf("Is log after 'Clear()' call empty: ")

if Get() == "" {
	fmt.Println("yes")
} else {
	fmt.Println("no")
}
Output:

Log output:
[LOG]: This is the log1
[LOG]: This is the log2

Is log after 'Clear()' call empty: yes

func NormalizeIPv4

func NormalizeIPv4(ipAddress string) string

NormalizeIPv4 will trim the zero padded IP address. For example, "001.001.001.001" will be "1.1.1.1".

**Note** that it is not a validator. If the given ipAddress is invalid it will return as is.

Types

This section is empty.

Jump to

Keyboard shortcuts

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