mirror of
https://github.com/status-im/status-console-client.git
synced 2025-02-24 16:48:09 +00:00
37 lines
634 B
Go
37 lines
634 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"io"
|
||
|
"strings"
|
||
|
"time"
|
||
|
|
||
|
"github.com/fatih/color"
|
||
|
)
|
||
|
|
||
|
type Notifications struct {
|
||
|
writer io.Writer
|
||
|
}
|
||
|
|
||
|
func (n *Notifications) Debug(title, message string) error {
|
||
|
str := fmt.Sprintf(
|
||
|
"%s | %s | %s",
|
||
|
title,
|
||
|
time.Now().Format(time.RFC822),
|
||
|
strings.TrimSpace(message),
|
||
|
)
|
||
|
_, err := color.New(color.FgYellow).Fprintln(n.writer, str)
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
func (n *Notifications) Error(title, message string) error {
|
||
|
str := fmt.Sprintf(
|
||
|
"%s | %s | %s",
|
||
|
title,
|
||
|
time.Now().Format(time.RFC822),
|
||
|
strings.TrimSpace(message),
|
||
|
)
|
||
|
_, err := color.New(color.FgRed).Fprintln(n.writer, str)
|
||
|
return err
|
||
|
}
|