From 1ef9d3ef49913ce73b2cdb7f51745ece40a7de1f Mon Sep 17 00:00:00 2001 From: Christian Ezeani Date: Mon, 28 Oct 2024 20:06:37 +0100 Subject: [PATCH] Add log.Color() --- log/logger.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/log/logger.go b/log/logger.go index 8f13371..aac9204 100644 --- a/log/logger.go +++ b/log/logger.go @@ -91,11 +91,21 @@ func New(opts Options) *Logger { } } -func Copy(x *Logger, color ...color.Attribute) *Logger { +func Copy(x *Logger, attr ...color.Attribute) *Logger { result := &Logger{Logger: x.Logger} - if len(color) > 0 { - result.SetColor(color[0]) + if len(attr) > 0 { + result.SetColor(attr[0]) + } + + return result +} + +func Color(attr ...color.Attribute) *Logger { + result := Default() + + if len(attr) > 0 { + result.SetColor(attr[0]) } return result