Documentation ¶
Index ¶
Constants ¶
const (
DefaultLoggingThrottle = 200 * time.Millisecond
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ListTask ¶
type ListTask struct {
// contains filtered or unexported fields
}
ListTask is a Task implementation that logs all updates in a list where each entry is line-delimited.
For example:
entry #1 entry #2 msg: ..., done.
func NewListTask ¶
NewListTask instantiates a new *ListTask instance with the given message.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger logs a series of tasks to an io.Writer, processing each task in order until completion .
func NewLogger ¶
NewLogger returns a new *Logger instance that logs to "sink" and uses the current terminal width as the width of the line. Will log progress status if stdout is a terminal or if forceProgress is true
func (*Logger) Close ¶
func (l *Logger) Close()
Close closes the queue and does not allow new Tasks to be `enqueue()`'d. It waits until the currently running Task has completed.
func (*Logger) Percentage ¶
func (l *Logger) Percentage(msg string, total uint64) *PercentageTask
Percentage creates and enqueues a new *PercentageTask.
func (*Logger) Simple ¶
func (l *Logger) Simple() *SimpleTask
Simple creates and enqueues a new *SimpleTask.
func (*Logger) Waiter ¶
func (l *Logger) Waiter(msg string) *WaitingTask
Waiter creates and enqueues a new *WaitingTask.
type Option ¶
type Option func(*Logger)
Option is the type for
func ForceProgress ¶
ForceProgress returns an options function that configures forced progress status on the logger.
type PercentageTask ¶
type PercentageTask struct {
// contains filtered or unexported fields
}
PercentageTask is a task that is performed against a known number of elements.
func NewPercentageTask ¶
func NewPercentageTask(msg string, total uint64) *PercentageTask
func (*PercentageTask) Complete ¶ added in v3.4.0
func (c *PercentageTask) Complete()
Complete notes that the task is completed by setting the number of completed elements to the total number of elements, and if necessary closing the Updates channel, which yields the logger to the next Task.
func (*PercentageTask) Count ¶
func (c *PercentageTask) Count(n uint64) (new uint64)
Count indicates that work has been completed against "n" number of elements, marking the task as complete if the total "n" given to all invocations of this method is equal to total.
Count returns the new total number of (atomically managed) elements that have been completed.
func (*PercentageTask) Entry ¶
func (c *PercentageTask) Entry(update string)
Entry logs a line-delimited task entry.
func (*PercentageTask) Throttled ¶
func (c *PercentageTask) Throttled() bool
Throttled implements Task.Throttled and returns true, indicating that this task is throttled.
func (*PercentageTask) Updates ¶
func (c *PercentageTask) Updates() <-chan *Update
Updates implements Task.Updates and returns a channel which is written to when the state of this task changes, and closed when the task is completed.
type SimpleTask ¶
type SimpleTask struct {
// contains filtered or unexported fields
}
SimpleTask is in an implementation of tasklog.Task which prints out messages verbatim.
func NewSimpleTask ¶
func NewSimpleTask() *SimpleTask
NewSimpleTask returns a new *SimpleTask instance.
func (*SimpleTask) Complete ¶
func (s *SimpleTask) Complete()
Complete notes that the task is completed by closing the Updates channel and yields the logger to the next Task. Complete blocks until the *tasklog.Logger has acknowledged completion of this task.
func (*SimpleTask) Log ¶
func (s *SimpleTask) Log(str string)
Log logs a string with no formatting verbs.
func (*SimpleTask) Logf ¶
func (s *SimpleTask) Logf(str string, vals ...interface{})
Logf logs some formatted string, which is interpreted according to the rules defined in package "fmt".
func (*SimpleTask) OnComplete ¶
func (s *SimpleTask) OnComplete()
OnComplete implements an interface which receives a call to this method when the *tasklog.Logger has finished processing this task, but before it has accepted new tasks.
func (*SimpleTask) Throttled ¶
func (s *SimpleTask) Throttled() bool
Throttled implements Task.Throttled and returns false, indicating that this task is not throttled.
func (*SimpleTask) Updates ¶
func (s *SimpleTask) Updates() <-chan *Update
Updates implements Task.Updates and returns a channel of updates which is closed when Complete() is called.
type Task ¶
type Task interface { // Updates returns a channel which is written to with the current state // of the Task when an update is present. It is closed when the task is // complete. Updates() <-chan *Update // Throttled returns whether or not updates from this task should be // limited when being printed to a sink via *log.Logger. // // It is expected to return the same value for a given Task instance. Throttled() bool }
Task is an interface which encapsulates an activity which can be logged.
type Update ¶
type Update struct { // S is the message sent in this update. S string // At is the time that this update was sent. At time.Time // Force determines if this update should not be throttled. Force bool }
Update is a single message sent (S) from a Task at a given time (At).
type WaitingTask ¶
type WaitingTask struct {
// contains filtered or unexported fields
}
WaitingTask represents a task for which the total number of items to do work is on is unknown.
func NewWaitingTask ¶
func NewWaitingTask(msg string) *WaitingTask
NewWaitingTask returns a new *WaitingTask.
func (*WaitingTask) Complete ¶
func (w *WaitingTask) Complete()
Complete marks the task as completed.
func (*WaitingTask) Throttled ¶
func (w *WaitingTask) Throttled() bool
Throttled implements Task.Throttled and returns true, indicating that this task is Throttled.
func (*WaitingTask) Updates ¶
func (w *WaitingTask) Updates() <-chan *Update
Updates implements the Task.Updates function and returns a channel of updates to log to the sink.