| 1 |
package main |
| 2 |
|
| 3 |
import ( |
| 4 |
"fmt" |
| 5 |
"time" |
| 6 |
|
| 7 |
"github.com/kataras/pio" |
| 8 |
"github.com/sirupsen/logrus" |
| 9 |
) |
| 10 |
|
| 11 |
func init() { |
| 12 |
// take an output from a print function |
| 13 |
output := pio.OutputFrom.Printf(logrus.Errorf) |
| 14 |
// register a new printer with name "logrus" |
| 15 |
// which will be able to read text and print as string. |
| 16 |
pio.Register("logrus", output).Marshal(pio.Text) |
| 17 |
} |
| 18 |
|
| 19 |
func main() { |
| 20 |
for i := 1; i <= 5; i++ { |
| 21 |
<-time.After(time.Second) |
| 22 |
pio.Print(fmt.Sprintf("[%d] This is an error message that will be printed to the logrus' printer", i)) |
| 23 |
} |
| 24 |
} |