cmd

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Gray    = "\033[90m"
	Red     = "\033[31m"
	Green   = "\033[32m"
	Yellow  = "\033[33m"
	Blue    = "\033[34m"
	Magenta = "\033[35m"
	Cyan    = "\033[36m"
	White   = "\033[37m"
	Reset   = "\033[0m"
)
View Source
var CmdOptions struct {
	OutputOptions
	Completion     *flags.EnumFlag
	ConfigFile     string
	LogDestination string
	LocalTime      bool
	Timezone       string
	UsePager       bool
	Verbose        bool
	Debug          bool
}

CmdOptions contains the global options

View Source
var LevelColors = map[int]string{
	0:  Blue,
	10: Gray,
	20: Yellow,
	30: Green,
	40: Magenta,
	50: Red,
	60: Red,
}
View Source
var RootCmd = &cobra.Command{
	Short: "pretty-print Bunyan logs from stdin or file(s)",
	Long:  "Bunyan is a simple and fast JSON log viewer. It reads log entries from given files or stdin and pretty-prints them to stdout.",
	RunE:  runRootCommand,
}

RootCmd represents the base command when called without any subcommands

View Source
var TimezoneAbbreviations = map[string]int{}/* 201 elements not displayed */

Functions

func Execute

func Execute(context context.Context) error

Execute run the command

func GetPager

func GetPager(context context.Context) (output io.WriteCloser, close func(), err error)

func ParseLocation

func ParseLocation(location string) (*time.Location, error)

Types

type AllLogFilter

type AllLogFilter struct{}

func (AllLogFilter) Filter

func (filter AllLogFilter) Filter(_ context.Context, _ LogEntry) bool

type AndNode

type AndNode struct {
	Left  ConditionNode
	Right ConditionNode
}

func (AndNode) Evaluate

func (node AndNode) Evaluate(entry LogEntry) bool

type BooleanNode

type BooleanNode struct {
	Value bool
}

func (BooleanNode) GetValue

func (node BooleanNode) GetValue(entry LogEntry) string

func (BooleanNode) String

func (node BooleanNode) String() string

type ConditionLogFilter

type ConditionLogFilter struct {
	Condition ConditionNode
}

func NewConditionFilter

func NewConditionFilter(condition string) (*ConditionLogFilter, error)

func (ConditionLogFilter) Filter

func (filter ConditionLogFilter) Filter(context context.Context, entry LogEntry) bool

type ConditionNode

type ConditionNode interface {
	Evaluate(entry LogEntry) bool
}

func ParseCondition

func ParseCondition(condition string) (ConditionNode, error)

type ConstantNode

type ConstantNode struct {
	Value string
}

func (ConstantNode) GetValue

func (node ConstantNode) GetValue(entry LogEntry) string

func (ConstantNode) String

func (node ConstantNode) String() string

type EqualsNode

type EqualsNode struct {
	Left  LeafNode
	Right LeafNode
}

func CreateEqualNode

func CreateEqualNode(left, right string) EqualsNode

func (EqualsNode) Evaluate

func (node EqualsNode) Evaluate(entry LogEntry) bool

type FieldNode

type FieldNode struct {
	Name string
}

func (FieldNode) GetValue

func (node FieldNode) GetValue(entry LogEntry) string

func (FieldNode) String

func (node FieldNode) String() string

type LeafNode

type LeafNode interface {
	fmt.Stringer
	GetValue(entry LogEntry) string
}

func ParseLeafNode

func ParseLeafNode(value string) LeafNode

type LevelLogFilter

type LevelLogFilter struct {
	LevelSet logger.LevelSet
}

func NewLevelLogFilter

func NewLevelLogFilter(level string) *LevelLogFilter

func (LevelLogFilter) Filter

func (filter LevelLogFilter) Filter(context context.Context, entry LogEntry) bool

type LogEntry

type LogEntry struct {
	Time     time.Time `json:"time"`
	Level    LogLevel  `json:"level"`
	Hostname string    `json:"hostname"`
	Name     string    `json:"name"`
	PID      int64     `json:"pid"`
	TaskID   int64     `json:"tid"`
	Topic    string    `json:"topic"`
	Scope    string    `json:"scope"`
	Message  string    `json:"msg"`
	Fields   map[string]any
	Blobs    map[string]any
}

LogEntry represents a log entry

func (LogEntry) GetField

func (entry LogEntry) GetField(name string) string

GetField retrieves the value of a specific field from the LogEntry.

func (*LogEntry) UnmarshalJSON

func (entry *LogEntry) UnmarshalJSON(payload []byte) (err error)

UnmarshalJSON unmarshal data into this

func (LogEntry) Write

func (entry LogEntry) Write(context context.Context, output io.Writer, options *OutputOptions)

Write writes the LogEntry to the given io.Writer output The output will be formatted according to the OutputOptions

type LogFilter

type LogFilter interface {
	Filter(context context.Context, entry LogEntry) bool
}

type LogLevel

type LogLevel logger.Level

func (LogLevel) String

func (level LogLevel) String() string

func (LogLevel) Write

func (level LogLevel) Write(output io.Writer, options *OutputOptions)

type MatchNode

type MatchNode struct {
	Left  LeafNode
	Right LeafNode
}

func CreateMatchNode

func CreateMatchNode(left, right LeafNode) (MatchNode, error)

func (MatchNode) Evaluate

func (node MatchNode) Evaluate(entry LogEntry) bool

type MultiLogFilter

type MultiLogFilter struct {
	Filters []LogFilter
}

func (*MultiLogFilter) Add

func (filter *MultiLogFilter) Add(filters ...LogFilter) *MultiLogFilter

func (MultiLogFilter) AsFilter

func (filter MultiLogFilter) AsFilter() LogFilter

func (MultiLogFilter) Filter

func (filter MultiLogFilter) Filter(context context.Context, entry LogEntry) bool

func (MultiLogFilter) IsEmpty

func (filter MultiLogFilter) IsEmpty() bool

type NotNode

type NotNode struct {
	Node ConditionNode
}

func (NotNode) Evaluate

func (node NotNode) Evaluate(entry LogEntry) bool

type NumberNode

type NumberNode struct {
	Value float64
}

func (NumberNode) GetValue

func (node NumberNode) GetValue(entry LogEntry) string

func (NumberNode) String

func (node NumberNode) String() string

type OrNode

type OrNode struct {
	Left  ConditionNode
	Right ConditionNode
}

func (OrNode) Evaluate

func (node OrNode) Evaluate(entry LogEntry) bool

type OutputOptions

type OutputOptions struct {
	LogLevel  string
	Filter    string
	Output    *flags.EnumFlag
	Location  *time.Location
	UseColors bool
}

type RegexNode

type RegexNode struct {
	Regex *regexp.Regexp
}

func (RegexNode) GetValue

func (node RegexNode) GetValue(entry LogEntry) string

func (RegexNode) String

func (node RegexNode) String() string

Jump to

Keyboard shortcuts

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