-
Notifications
You must be signed in to change notification settings - Fork 0
/
stdres_test.go
29 lines (23 loc) · 1.16 KB
/
stdres_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package stdres_test
import "github.com/dekelund/stdres"
func Example() {
var buffer stdres.Buffer
buffer = stdres.Buffer{}
firstAction := buffer.Println("Executing first action")
secondAction := buffer.Println("Executing second action")
thirdAction := buffer.Println("Executing third action")
fourthAction := buffer.Printf("Executing fourth action, printed with number one - %d\n", 1)
buffer.Print("Executing fifth action") // Never updated, printed with UNKNOWN state which result in Cyan color
firstAction.Result = stdres.SUCCESS // First action succeeded, line printed in green
secondAction.Result = stdres.FAILURE // Second action failed, line printed in red
thirdAction.Result = stdres.INFO // Third action was just information, line printed in blue
fourthAction.Result = stdres.PLAIN // Fourth action printed with white text
stdres.DisableColor() // Use this method to remove color output
buffer.Flush() // Only print if and when we flush, update result before flush.
// Output:
// Executing first action
// Executing second action
// Executing third action
// Executing fourth action, printed with number one - 1
// Executing fifth action
}