report

package
v0.2.2-0...-52a3941 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: CC0-1.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const TemplateSimple = `` /* 173-byte string literal not displayed */

TemplateSimple constant for simple html pongo2 template

Variables

View Source
var LogLevelArray = []string{"Debug", "Info", "Warn", "Error", "Fatal"}

LogLevelArray string denoting levels of logs

View Source
var LogLevelMap = map[string]int{
	"debug": 0,
	"info":  1,
	"warn":  2,
	"error": 3,
	"fatal": 4,
}

LogLevelMap a map that holds the integer for a log level

Functions

This section is empty.

Types

type DistributionFormat

type DistributionFormat struct {
	Severity struct {
		Debug []string `yaml:"debug,omitempty"`
		Info  []string `yaml:"info,omitempty"`
		Warn  []string `yaml:"warn,omitempty"`
		Error []string `yaml:"error,omitempty"`
		Fatal []string `yaml:"fatal,omitempty"`
	} `yaml:"severity"`
}

DistributionFormat is for unmarshiling a email distributionList file

func ReadDistributionFormatYAMLFromFile

func ReadDistributionFormatYAMLFromFile(path string) (format DistributionFormat, err error)

ReadDistributionFormatYAMLFromFile loads DistributionFormat data from a YAML file

func (DistributionFormat) GetEmails

func (df DistributionFormat) GetEmails(level string) []string

GetEmails returns list of emails based on log level

func (DistributionFormat) Print

func (df DistributionFormat) Print()

Print the DistributionFormat

type Element

type Element interface {
	GetHeaders() []string
	GetValue(key string) string
}

Element interface for anything that is contained in a report

type EmailHandler

type EmailHandler struct {
	SMTPHost    string
	SMTPPort    string
	SenderEmail string
	SenderName  string
	Recipients  []string
	Subject     string
	HTML        bool
}

EmailHandler initilization should contain any variables used for report

func (EmailHandler) HandleReport

func (eh EmailHandler) HandleReport(reader io.Reader) (err error)

HandleReport consumes ReportReader output, writes to file

type FileHandler

type FileHandler struct {
	Filename string
}

FileHandler initilization should contain any variables used for report

func (FileHandler) HandleReport

func (fr FileHandler) HandleReport(reader io.Reader) (err error)

HandleReport consumes ReportReader output, writes to file

type Handler

type Handler interface {
	HandleReport(io.Reader) error
}

Handler interface for anything able to consume a report

type JSONReportRunner

type JSONReportRunner struct{}

JSONReportRunner initilization should contain any variables used for report

func (JSONReportRunner) ReportReader

func (jrr JSONReportRunner) ReportReader(reportSet Set) (io.Reader, error)

ReportReader Implementation for JSONReportRunner

type PGHandler

type PGHandler struct {
	Cxn *sql.DB
}

PGHandler initilization with sql connection

func (PGHandler) HandleReport

func (pg PGHandler) HandleReport(reader io.Reader) (err error)

HandleReport consumes ReportReader output, writes to postgres db

type Pongo2ReportRunner

type Pongo2ReportRunner struct {
	Template pongo2.Template
	StyleCSS bool
}

Pongo2ReportRunner initilization with template object

func NewPongo2ReportRunnerFromFile

func NewPongo2ReportRunnerFromFile(TemplateFilePath string) *Pongo2ReportRunner

NewPongo2ReportRunnerFromFile constructor with template file

func NewPongo2ReportRunnerFromString

func NewPongo2ReportRunnerFromString(TemplateString string, StyleCSS bool) *Pongo2ReportRunner

NewPongo2ReportRunnerFromString constructor with template string

func (Pongo2ReportRunner) ReportReader

func (p2rr Pongo2ReportRunner) ReportReader(reportSet Set) (io.Reader, error)

ReportReader Implementation for Pongo2ReportRunner

type PrintHandler

type PrintHandler struct{}

PrintHandler initilization should contain any variables used for report

func (PrintHandler) HandleReport

func (pr PrintHandler) HandleReport(reader io.Reader) (err error)

HandleReport consumes ReportReader output, prints to stdout

type Runner

type Runner interface {
	ReportReader(Set) (io.Reader, error)
}

Runner interface for anything able to generate a report

type Set

type Set struct {
	Elements []Element
	Metadata map[string]interface{}
}

Set structure for containing elements and metadata for a report

func FilterReportSet

func FilterReportSet(rs Set, logLevel string) Set

FilterReportSet by the logLevel

func (*Set) GetElementArray

func (rs *Set) GetElementArray() []Element

GetElementArray getter for Elements

func (*Set) GetMetadata

func (rs *Set) GetMetadata() map[string]interface{}

GetMetadata getter for Metadata

func (*Set) GetReportMap

func (rs *Set) GetReportMap() map[string]interface{}

GetReportMap converts a ReportSet to generic go map

Jump to

Keyboard shortcuts

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