utils

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Green = "\033[32m"
View Source
var Logger *log.Logger
View Source
var Red = "\033[31m"
View Source
var Reset = "\033[0m"
View Source
var Yellow = "\033[33m"

Functions

func ABool

func ABool(args []string, index int, def bool) bool

func AInt

func AInt(args []string, index int, def int) int

func AString

func AString(args []string, index int, def string) string

func CheckUpdatesAndPrintInfo

func CheckUpdatesAndPrintInfo(version string)

func InitLogger

func InitLogger()

func LineCounter

func LineCounter(r io.Reader) (int, error)

func LineCounterWithChannel

func LineCounterWithChannel(r io.Reader, fn func(line Line, cancel func())) error

func LoadFile

func LoadFile(configFilePath string) string

func OpenFileForReading

func OpenFileForReading(file string) (io.Reader, int64)

func OpenFileForReadingWithProgress

func OpenFileForReadingWithProgress(file string) (io.Reader, int64, *pb.ProgressBar)

func PickRandom

func PickRandom[T any](slice []T) T

func ProcessIncomingMessages

func ProcessIncomingMessages(ch chan models.Message, appendToFile string, appendToFileRaw bool) chan models.Message

func RandStringRunes

func RandStringRunes(n int) string

func SetLoggerDiscard

func SetLoggerDiscard(discard bool)

func SetLoggerInterceptor

func SetLoggerInterceptor(fn LogInterceptor)

func SetLoggerLevel

func SetLoggerLevel(verbose bool)

func StripAnsi

func StripAnsi(str string) string

func Trunc

func Trunc(str string, limit int) string

Types

type CustomHook

type CustomHook struct {
	// contains filtered or unexported fields
}

func (*CustomHook) Fire

func (hook *CustomHook) Fire(entry *logrus.Entry) error

Fire is called whenever a log entry is made

func (*CustomHook) Levels

func (hook *CustomHook) Levels() []logrus.Level

Levels returns the log levels that this hook will be fired for

type LOG_LEVEL

type LOG_LEVEL int
const LOG_LEVEL_NORMAL LOG_LEVEL = 1
const LOG_LEVEL_SILENT LOG_LEVEL = 0
const LOG_LEVEL_VERBOSE LOG_LEVEL = 2

type Line

type Line struct {
	Line []byte
	// contains filtered or unexported fields
}

type LogEntry

type LogEntry struct {
	Data map[string]interface{}
	Time time.Time

	// Level the log entry was logged at: Trace, Debug, Info, Warn, Error, Fatal or Panic
	// This field will be set on entry firing and the value will be equal to the one in Logger struct field.
	Level int

	// Calling method, with package name
	Caller *runtime.Frame

	// Message passed to Trace, Debug, Info, Warn, Error, Fatal or Panic
	Message string
}

type LogInterceptor

type LogInterceptor func(entry *LogEntry)

type UpdateResponse

type UpdateResponse struct {
	CurrentVersion          string `json:"current_version"`
	CurrentVersionPublished string `json:"current_version_published"`
	DownloadLink            string `json:"download_link"`
	BlogLink                string `json:"blog_link"`
	Excerpt                 string `json:"excerpt"`
}

Jump to

Keyboard shortcuts

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