/usr/share/gocode/src/github.com/hlandau/xlog/severity.go is in golang-github-hlandau-xlog-dev 1.0.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | package xlog
import "strings"
// Log message severity. This is the syslog severity order.
//
// Note that Emergency and Alert are system-level severities. Generally
// speaking, application programs should not emit log messages at such
// severities unless they are programs which monitor the system for
// system-level issues. i.e., programs should never emit Emergency or Alert
// messages regarding issues with their own operation.
//
// Programs suffering from critical failures should emit log messages at the
// Critical severity. The Panic*() and Fatal*() log message functions in this
// package emit log messages at the Critical level.
//
// The Error severity should be used when errors occur which do not constitute
// a critical or unrecoverable failure of the program.
//
// Any severity less severe than Debug is not part of the syslog severity
// order. These are converted to messages of Debug severity when exported
// to e.g. syslog.
//
// Trace should be used for extremely verbose debugging information which
// is likely to be used mainly for debugging and is of such verbosity that it
// may overwhelm a programmer unless enabled only for a few specific
// facilities.
type Severity int
const (
SevEmergency Severity = iota
SevAlert
SevCritical
SevError
SevWarn
SevNotice
SevInfo
SevDebug
SevTrace
SevNone Severity = -1 // (Do not use.)
)
var severityString = map[Severity]string{
SevEmergency: "EMERGENCY", // EM EMR EMER
SevAlert: "ALERT", // AL ALR ALER
SevCritical: "CRITICAL", // CR CRT CRIT
SevError: "ERROR", // ER ERR ERRO
SevWarn: "WARN", // WA WRN WARN
SevNotice: "NOTICE", // NO NOT NOTC
SevInfo: "INFO", // IN INF INFO
SevDebug: "DEBUG", // DE DBG DEBG
SevTrace: "TRACE", // TR TRC TRAC
}
var ansiSeverityString = map[Severity]string{
SevEmergency: "\x1B[41;37mEMERGENCY\x1B[0m",
SevAlert: "\x1B[41;37mALERT\x1B[0m",
SevCritical: "\x1B[41;37mCRITICAL\x1B[0m",
SevError: "\x1B[31mERROR\x1B[0m",
SevWarn: "\x1B[33mWARN\x1B[0m",
SevNotice: "NOTICE\x1B[0m",
SevInfo: "INFO\x1B[0m",
SevDebug: "DEBUG\x1B[0m",
SevTrace: "TRACE\x1B[0m",
}
var severityValue = map[string]Severity{}
func init() {
for k, v := range severityString {
severityValue[v] = k
}
}
// Returns the severity as an uppercase unabbreviated string.
func (severity Severity) String() string {
return severityString[severity]
}
// Parse a severity string.
func ParseSeverity(severity string) (s Severity, ok bool) {
s, ok = severityValue[strings.ToUpper(severity)]
return
}
// Returns the syslog-compatible severity. Converts severities
// less severe than Debug to Debug.
func (severity Severity) Syslog() Severity {
if severity > SevDebug {
return SevDebug
}
return severity
}
|