From 6328a424395206226bb76b1c3475fb92496a133f Mon Sep 17 00:00:00 2001 From: Gregory Rudolph Date: Thu, 9 Jan 2020 09:41:50 -0500 Subject: [PATCH] Added LogPanic() shortcut and removed termination from LogCritical(), also added channel tag to error/critical values. --- loggy.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/loggy.go b/loggy.go index fd0a9dd..34e94e4 100644 --- a/loggy.go +++ b/loggy.go @@ -96,8 +96,13 @@ func (l Logger) toFile(msg Log) { // Send log to Keybase func (l Logger) toKeybase(msg Log) { - output := fmt.Sprintf("[%s] %s", - l.opts.ProgName, msg.String()) + tag := "" + if msg.Level <= 2 { + tag = "@everyone " + } + output := fmt.Sprintf("[%s] %s%s", + l.opts.ProgName, tag, msg.String()) + chat := l.k.NewChat(l.team) chat.Send(output) @@ -144,12 +149,18 @@ func (l Logger) LogError(msg string) { } // Log Critical shortcut from string -// !!! This will terminate the program !!! func (l Logger) LogCritical(msg string) { var logMsg Log logMsg.Level = Critical logMsg.Msg = msg - // Handles log, then terminates program + handleLog(l, logMsg) +} + +// Log Critical shortcut that terminates progra +func (l Logger) LogPanic(msg string) { + var logMsg Log + logMsg.Level = Critical + logMsg.Msg = msg handleLog(l, logMsg) os.Exit(-1) }