Documentation ¶
Overview ¶
Package display implements functions for displaying output to users.
Index ¶
- Variables
- func ClearProgress()
- func File() string
- func Handler(entry *log.Entry) error
- func InProgress(message string)
- func JSON(data interface{}) (int, error)
- func SetDebug(debug bool, setVerbose bool)
- func SetFile(filename string) error
- func SetInteractive(interactive bool)
- func SyncFile() error
- func Template(tmpl *template.Template, data interface{}) (string, error)
- func TemplateFile(filename string, data interface{}) (string, error)
- func TemplateFormatTabs(tmpl string, data interface{}, minWidth, tabWidth, padding int) (string, error)
- func TemplateString(templateString string, data interface{}) (string, error)
- func Test()
- type Display
- type ProgressTracker
Constants ¶
This section is empty.
Variables ¶
var TestHandler log.Handler
TestHandler collects log entries during testing.
Functions ¶
func Handler ¶
Handler handles log entries. It multiplexes them into two outputs, writing human-readable messages to STDERR and machine-readable entries to a log file.
TODO: does this need to be synchronised?
func InProgress ¶
func InProgress(message string)
InProgress shows a progress spinner with a message.
func SetDebug ¶
SetDebug turns debug logging to STDERR on or off.
The log file always writes debug-level entries.
func SetInteractive ¶
func SetInteractive(interactive bool)
SetInteractive turns colors and ANSI control characters on or off.
func SyncFile ¶ added in v1.0.10
func SyncFile() error
SyncFile syncs the FOSSA log file and writes all progress to disk.
func TemplateFile ¶
TemplateFile renders a template file and its context to string.
func TemplateFormatTabs ¶ added in v0.7.27
func TemplateFormatTabs(tmpl string, data interface{}, minWidth, tabWidth, padding int) (string, error)
TemplateFormatTabs renders a template with the desired tab format.
func TemplateString ¶ added in v0.7.27
TemplateString renders a template from a string template.
Types ¶
type Display ¶ added in v1.0.5
type Display interface { // Start a new process and start tracking its progress // `StartProcess("nodejs")` // -> [] nodejs StartProcess(processName string) ProgressTracker // Stop the progress display. All future updates from processes will be ignored Stop() }
A Display provides progress indicators for running "processes".
Running "process" indicators are joined by spaces, e.g., [] nodejs(Discovery) golang(Analysis 1/5)
See ProgressTracker for examples
func StartDisplay ¶ added in v1.0.5
func StartDisplay() Display
type ProgressTracker ¶ added in v1.0.5
type ProgressTracker interface { // Begin a new step in this process // Clears the current count of Completed and Tasks Begin(stepName string) // Update the number of completed actions // When called before `AddTasks`, the count of tasks will display as "?" AddCompleted(n int) // Update the number of tasks that need to be run // When called before `AddCompleted`, the count of completed will display as "0" AddTasks(n int) // End the progress tracker for this process // // NOTE: When reusing the same ProgressTracker, be sure to call `Begin` End() }
A ProgressTracker is created by calling `Display.StartProcess(processName string)`
A ProgressTracker is used to show the current step and progress for a given"process" Examples below are using `Display.StartProcess("nodejs")`
`Begin("Discovery")` -> [] nodejs(Discovery)
`Begin("Discovery")` `AddCompleted(5)` -> [] nodejs(Discovery 5/?)
`Begin("Analysis")` `AddTasks(5)` -> [] nodejs(Analysis 0/5) `AddCompleted(1)` -> [] nodejs(Analysis 1/5)
`End()` -> []
NOTE: only the `AddCompleted` and `AddTasks` functions are safe to be called concurrently.