Browse Source

Added LogPanic() shortcut and removed termination from LogCritical(), also added channel tag to error/critical values.

pull/1/head
Gregory Rudolph 5 years ago
parent
commit
6328a42439
  1. 19
      loggy.go

19
loggy.go

@ -96,8 +96,13 @@ func (l Logger) toFile(msg Log) {
// Send log to Keybase // Send log to Keybase
func (l Logger) toKeybase(msg Log) { func (l Logger) toKeybase(msg Log) {
output := fmt.Sprintf("[%s] %s", tag := ""
l.opts.ProgName, msg.String()) 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 := l.k.NewChat(l.team)
chat.Send(output) chat.Send(output)
@ -144,12 +149,18 @@ func (l Logger) LogError(msg string) {
} }
// Log Critical shortcut from string // Log Critical shortcut from string
// !!! This will terminate the program !!!
func (l Logger) LogCritical(msg string) { func (l Logger) LogCritical(msg string) {
var logMsg Log var logMsg Log
logMsg.Level = Critical logMsg.Level = Critical
logMsg.Msg = msg 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) handleLog(l, logMsg)
os.Exit(-1) os.Exit(-1)
} }

Loading…
Cancel
Save