mirror of
https://github.com/muraenateam/muraena.git
synced 2026-01-23 02:24:05 +00:00
61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
package log
|
|
|
|
import (
|
|
"github.com/evilsocket/islazy/tui"
|
|
)
|
|
|
|
// Verbosity represents the verbosity level of the logger.
|
|
type Verbosity int
|
|
|
|
const (
|
|
// Verbose messages
|
|
VERBOSE Verbosity = iota
|
|
// Debug messages.
|
|
DEBUG
|
|
// Informative messages.
|
|
INFO
|
|
// Informative messages that are important.
|
|
IMPORTANT
|
|
// Warning messages.
|
|
WARNING
|
|
// Recoverable error conditions.
|
|
ERROR
|
|
// Fatal error conditions.
|
|
FATAL
|
|
)
|
|
|
|
var (
|
|
// LevelNames is a map of the names ( {level:name} ) of each verbosity level.
|
|
LevelNames = map[Verbosity]string{
|
|
VERBOSE: "ver",
|
|
DEBUG: "dbg",
|
|
INFO: "inf",
|
|
IMPORTANT: "imp",
|
|
WARNING: "war",
|
|
ERROR: "err",
|
|
FATAL: "!!!",
|
|
}
|
|
// LevelColors is a map of the colors ( {level:color} ) of each verbosity level.
|
|
LevelColors = map[Verbosity]string{
|
|
VERBOSE: tui.DIM + tui.FOREBLACK + tui.BACKYELLOW,
|
|
DEBUG: tui.DIM + tui.FOREBLACK + tui.BACKDARKGRAY,
|
|
INFO: tui.FOREWHITE + tui.BACKGREEN,
|
|
IMPORTANT: tui.FOREWHITE + tui.BACKLIGHTBLUE,
|
|
WARNING: tui.FOREWHITE + tui.BACKYELLOW,
|
|
ERROR: tui.FOREWHITE + tui.BACKRED,
|
|
FATAL: tui.FOREWHITE + tui.BACKRED + tui.BOLD,
|
|
}
|
|
)
|
|
|
|
// LevelName returns the name of a verbosity level.
|
|
func LevelName(v Verbosity) string {
|
|
return LevelNames[v]
|
|
}
|
|
|
|
// LevelColor returns the color of a verbosity level or "" if effects are disabled.
|
|
func LevelColor(v Verbosity) string {
|
|
if NoEffects {
|
|
return ""
|
|
}
|
|
return LevelColors[v]
|
|
}
|