Top.Mail.Ru
package console — KubFly SDK for Go

KubFly SDK for Go / output/console

package console

import "kubfly.io/sdk/output/console"

Package console is the console as an output of the pipeline (kubfly.io/sdk/pipeline) — kubfly-sdk-output-console of the Java SDK: the records after the ordering window, as pretty lines for people or JSON lines for machines, on the standard output or error. Frames and events are written from the bodies without allocating (format.RecordReader); the lines of a drain go as one batch through an Outlet, so a slow terminal never holds the application: with the ring full, the lines are lost and counted on a line of their own.

The package registers itself with the pipeline: linking it in is all it takes, and it is on unless KUBFLY_OUTPUT_CONSOLE=OFF.

import _ "kubfly.io/sdk/output/console"

Constants

const Name = "console"

Name is the name of the output.

Variables

var Config = registerConfig(loadConfig(api.Config.Vars))

Config is the configuration of the console, taken once from api.Config.Vars when the package loads — the Config class of the Java SDK: the parameters sdk/output-console/*. Wrong values fall back to their defaults and are listed in Problems: WARN events of sdk/output-console/output/console once the process starts.

Types

type Configuration

type Configuration struct {
	// Console tells whether the console is on (KUBFLY_OUTPUT_CONSOLE): on and auto — on (by default), off — never.
	Console *api.Param[bool]
	// Format is the format of the lines (KUBFLY_OUTPUT_CONSOLE_FORMAT).
	Format *api.Param[lineFormat]
	// Color tells whether the lines are colored (KUBFLY_OUTPUT_CONSOLE_COLOR).
	Color *api.Param[util.Switch]
	// Stream is where the lines go (KUBFLY_OUTPUT_CONSOLE_STREAM).
	Stream *api.Param[stream]
	// Level is the most verbose level of the events printed (KUBFLY_OUTPUT_CONSOLE_LEVEL).
	Level *api.Param[api.Level]
	// Events tells whether events, alerts and health are printed (KUBFLY_OUTPUT_CONSOLE_EVENTS).
	Events *api.Param[util.Switch]
	// Frames tells whether the beginnings and the ends of frames are printed (KUBFLY_OUTPUT_CONSOLE_FRAMES).
	Frames *api.Param[bool]
	// Metrics are the busiest metrics printed of an interval (KUBFLY_OUTPUT_CONSOLE_METRICS).
	Metrics *api.Param[int]
	// Traffic are the busiest edges printed of an interval (KUBFLY_OUTPUT_CONSOLE_TRAFFIC).
	Traffic *api.Param[int]
	// Profiles are the hottest frames printed of a profile (KUBFLY_OUTPUT_CONSOLE_PROFILES).
	Profiles *api.Param[int]
	// Settings are what the console prints and how: the values of the parameters.
	Settings Settings
	// Problems are the wrong values that fell back to their defaults.
	Problems []string
}

Configuration is the configuration of the console.

type Output

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

Output is the console: a pipeline.Output and the owner of its batches.

func New

func New(p *pipeline.Pipeline, settings Settings, out io.Writer, colors bool, problems []string) *Output

New is a console of a pipeline that writes to a writer, colored or not, its goroutine started: for tests and tools; an application links the package in. The problems are the wrong settings: WARN events of sdk/output-console/output/console once the process starts.

func (*Output) Cycle

func (o *Output) Cycle(now int64, all bool)

Cycle sends the lines of the drain, after a line of what was lost.

func (*Output) Failures

func (o *Output) Failures() int64

Failures are the panics of the writer.

func (*Output) Finish

func (o *Output) Finish(time int64)

Finish prints what is left and stops the goroutine.

func (*Output) Flush

func (o *Output) Flush(now int64)

Flush returns when the lines sent so far are printed.

func (*Output) Frames

func (o *Output) Frames(project, module, area, system, component string) bool

Frames tells whether the console prints frames: KUBFLY_OUTPUT_CONSOLE_FRAMES, for every scope.

func (*Output) Level

func (o *Output) Level() api.Level

Level is the level of the settings, OFF while the events are not printed.

func (*Output) Lost

func (o *Output) Lost(records int64, now int64)

Lost counts the records the pipeline lost: a line at the next cycle.

func (*Output) Memory

func (o *Output) Memory() int64

Memory is the bytes the output holds: the lines in the batches of its outlet (its own buffers are a few KiB) — pipeline.OutputMemory.

func (*Output) Name

func (o *Output) Name() string

Name is console.

func (*Output) Record

func (o *Output) Record(record *pipeline.Record, now int64)

Record prints a record: a record it cannot read is a line that tells so, without its text.

func (*Output) Start

func (o *Output) Start(time int64)

Start defines the metrics of the console and reports the problems of the configuration as WARN events of sdk/output-console/output/console: on goroutines of their own, as the collectors may still be loading.

type Settings

type Settings struct {
	// JSON tells that the lines are JSON lines (KUBFLY_OUTPUT_CONSOLE_FORMAT=JSON), not pretty ones.
	JSON bool
	// Level is the most verbose level of the events printed (KUBFLY_OUTPUT_CONSOLE_LEVEL, INFO).
	Level api.Level
	// Events tells whether events, alerts and health are printed (KUBFLY_OUTPUT_CONSOLE_EVENTS); SwitchAuto — off
	// while a bridge prints the events itself.
	Events util.Switch
	// Frames tells whether the beginnings and the ends of frames are printed (KUBFLY_OUTPUT_CONSOLE_FRAMES, on).
	Frames bool
	// Metrics are the busiest metrics printed of an interval (KUBFLY_OUTPUT_CONSOLE_METRICS, 10); 0 — none.
	Metrics int
	// Traffic are the busiest edges printed of an interval (KUBFLY_OUTPUT_CONSOLE_TRAFFIC, 10); 0 — none.
	Traffic int
	// Profiles are the hottest frames printed of a profile (KUBFLY_OUTPUT_CONSOLE_PROFILES, 5); 0 — none.
	Profiles int
	// Color tells whether the lines are colored (KUBFLY_OUTPUT_CONSOLE_COLOR); SwitchAuto — on a terminal without
	// NO_COLOR.
	Color util.Switch
	// Stderr tells that the lines go to the standard error (KUBFLY_OUTPUT_CONSOLE_STREAM=STDERR).
	Stderr bool
}

Settings are what the console prints and how.