From a45dac3280ae49d939c90b98a143fdcb71c1ea11 Mon Sep 17 00:00:00 2001 From: Sam Caldwell Date: Thu, 21 Nov 2024 01:03:16 -0600 Subject: [PATCH] add error logging to ansi package --- error.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 error.go diff --git a/error.go b/error.go new file mode 100644 index 0000000..b4e9610 --- /dev/null +++ b/error.go @@ -0,0 +1,35 @@ +package ansi + +// Error - print error message +func Error(msg ...interface{}) *Color { + return (&Color{}).Error(msg...) +} + +// Errorf - print error message +func Errorf(format string, msg ...interface{}) *Color { + return (&Color{}).Errorf(format, msg...) +} + +// Errorln - print error message +func Errorln(msg ...interface{}) *Color { + return (&Color{}).Errorln(msg...) +} + +// Error - print error message +func (c *Color) Error(msg ...interface{}) *Color { + c.Red().Print("[ERROR]: ") + for _, m := range msg { + c.Print(m.(string)) + } + return c +} + +// Errorf - print error message +func (c *Color) Errorf(format string, msg ...interface{}) *Color { + return Red().Printf("[ERROR]: "+format, msg...) +} + +// Errorln - print error message +func (c *Color) Errorln(msg ...interface{}) *Color { + return c.Errorln(msg...).LF() +}