generator

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package generator provides log generation functionality for the genlog tool. It contains the core logic for creating fake log entries based on templates and random data generation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

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

Generator is responsible for generating fake log entries based on the provided configuration. It handles template selection, random value generation, and output management.

func NewGenerator

func NewGenerator(cfg *config.Config, maxCount int) (*Generator, error)

NewGenerator creates a new log generator with the given configuration. It initializes the function map for template rendering and calculates the total template weight for weighted random selection.

The function map includes all custom types from the configuration, making them available as placeholders in templates.

func (*Generator) Done added in v0.1.5

func (g *Generator) Done() chan struct{}

Done returns a channel that is closed when the generator has completed generating the requested number of logs

func (*Generator) GenerateLogLine

func (g *Generator) GenerateLogLine() (string, error)

GenerateLogLine generates a single log line using a randomly selected template. This is useful for generating log lines programmatically without writing to a file, such as when streaming logs directly to another system.

func (*Generator) Start added in v0.1.5

func (g *Generator) Start()

Start begins generating and sending logs to all configured outputs

func (*Generator) Stop added in v0.1.5

func (g *Generator) Stop() error

Stop gracefully stops all workers and closes outputs

Jump to

Keyboard shortcuts

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