diff options
author | msglm <msglm@techchud.xyz> | 2023-10-27 07:08:25 -0500 |
---|---|---|
committer | msglm <msglm@techchud.xyz> | 2023-10-27 07:08:25 -0500 |
commit | 032a7e0c1188d3507b8d9a9571f2446a43cf775b (patch) | |
tree | 2bd38c01bc7761a6195e426082ce7191ebc765a1 /vendor/maunium.net/go/maulogger/v2/level.go | |
parent | 56e7bd01ca09ad52b0c4f48f146a20a4f1b78696 (diff) | |
download | matterbridge-msglm-032a7e0c1188d3507b8d9a9571f2446a43cf775b.tar.gz matterbridge-msglm-032a7e0c1188d3507b8d9a9571f2446a43cf775b.tar.bz2 matterbridge-msglm-032a7e0c1188d3507b8d9a9571f2446a43cf775b.zip |
apply https://github.com/42wim/matterbridge/pull/1864v1.26.0+0.1.0
Diffstat (limited to 'vendor/maunium.net/go/maulogger/v2/level.go')
-rw-r--r-- | vendor/maunium.net/go/maulogger/v2/level.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/vendor/maunium.net/go/maulogger/v2/level.go b/vendor/maunium.net/go/maulogger/v2/level.go new file mode 100644 index 00000000..392dccd8 --- /dev/null +++ b/vendor/maunium.net/go/maulogger/v2/level.go @@ -0,0 +1,47 @@ +// mauLogger - A logger for Go programs +// Copyright (c) 2016-2021 Tulir Asokan +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +package maulogger + +import ( + "fmt" +) + +// Level is the severity level of a log entry. +type Level struct { + Name string + Severity, Color int +} + +var ( + // LevelDebug is the level for debug messages. + LevelDebug = Level{Name: "DEBUG", Color: -1, Severity: 0} + // LevelInfo is the level for basic log messages. + LevelInfo = Level{Name: "INFO", Color: 36, Severity: 10} + // LevelWarn is the level saying that something went wrong, but the program will continue operating mostly normally. + LevelWarn = Level{Name: "WARN", Color: 33, Severity: 50} + // LevelError is the level saying that something went wrong and the program may not operate as expected, but will still continue. + LevelError = Level{Name: "ERROR", Color: 31, Severity: 100} + // LevelFatal is the level saying that something went wrong and the program will not operate normally. + LevelFatal = Level{Name: "FATAL", Color: 35, Severity: 9001} +) + +// GetColor gets the ANSI escape color code for the log level. +func (lvl Level) GetColor() string { + if lvl.Color < 0 { + return "\x1b[0m" + } + return fmt.Sprintf("\x1b[%dm", lvl.Color) +} + +// GetReset gets the ANSI escape reset code. +func (lvl Level) GetReset() string { + if lvl.Color < 0 { + return "" + } + return "\x1b[0m" +} |