gotext

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package gotext implements the generator for generic logs.

Configuration file supports including timestamps in log messages

generator:
  type: gotext
  include_timestamp: true

Index

Constants

View Source
const Name = "gotext"

Name is the name of the generator in the configuration file and registry

Variables

View Source
var (
	FunctionMap = template.FuncMap{
		"ToLower":            strings.ToLower,
		"ToUpper":            strings.ToUpper,
		"TimestampFormatter": TimestampFormatter,
		"RandomIPv4":         RandomIPv4,
		"RandomPort":         RandomPort,
		"RandomInt":          RandomInt,
		"Percent":            Percent,
		"PlusInt":            PlusInt,
		"TimesInt":           TimesInt,
	}
)

Functions

func New

func New(cfg *ucfg.Config) (generator.Generator, error)

New is Factory for the gotext generator

func Percent

func Percent(numerator, denominator any) string

func PlusInt

func PlusInt(a, b any) string

func RandomDuration

func RandomDuration() string

func RandomIPv4

func RandomIPv4() string

func RandomInt

func RandomInt(maximum int) string

func RandomPort

func RandomPort() string

func TimesInt

func TimesInt(a, b any) string

func TimestampFormatter

func TimestampFormatter(format, whence string) string

func ToInt

func ToInt(input any) int

Types

type Field

type Field struct {
	Name    string   `config:"name"`
	Type    string   `config:"type"`
	Choices []string `config:"choices"`
	// contains filtered or unexported fields
}

type GcField

type GcField struct {
	Name     string   `config:"name"`
	Type     string   `config:"type"`
	Choices  []string `config:"choices"`
	Template *string  `config:"tpl"`
}

type GeneratorConfig

type GeneratorConfig struct {
	Name    string    `config:"name" validate:"required"`
	Formats []*string `config:"formats"`
	Fields  []GcField `config:"fields"`
}

type GoText

type GoText struct {
	Name   string
	Fields []Field
	// contains filtered or unexported fields
}

func (*GoText) Next

func (g *GoText) Next() ([]byte, error)

type Template

type Template struct {
	Format string
	Tpl    *template.Template
}

Jump to

Keyboard shortcuts

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