Documentation ¶
Index ¶
- Constants
- Variables
- func Add(pathBase string) (subsystem string)
- func AddFilteredSubsystem(hl string) struct{}
- func AddHighlightedSubsystem(hl string) struct{}
- func AddLogChan() (ch chan Entry)
- func Caller(comment string, skip int) string
- func DirectionString(inbound bool) string
- func FileExists(filePath string) bool
- func LoadHighlightedSubsystems() (o []string)
- func LoadSubsystemFilter() (o []string)
- func PickNoun(n int, singular, plural string) string
- func SetLogLevel(l string)
- func SetLogWriteToFile(path, appName string) (e error)
- func SetLogWriter(wr io.Writer)
- func StoreHighlightedSubsystems(highlights []string) (found bool)
- func StoreSubsystemFilter(filter []string)
- type Entry
- type LevelPrinter
- type LevelSpec
- type Logger
Constants ¶
const ( Off = "off" Fatal = "fatal" Error = "error" Warn = "warn" Info = "info" Check = "check" Debug = "debug" Trace = "trace" )
Variables ¶
var ( App = " main" AppColorizer = color.Gray.Sprint // LevelSpecs specifies the id, string name and color-printing function LevelSpecs = []LevelSpec{ { logLevels.Off, "off ", color.Bit24(0, 0, 0, false).Sprintf, }, { logLevels.Fatal, "fatal", color.Bit24(128, 0, 0, false).Sprintf, }, { logLevels.Error, "error", color.Bit24(255, 0, 0, false).Sprintf, }, { logLevels.Check, "check", color.Bit24(255, 255, 0, false).Sprintf, }, { logLevels.Warn, "warn ", color.Bit24(0, 255, 0, false).Sprintf, }, { logLevels.Info, "info ", color.Bit24(255, 255, 0, false).Sprintf, }, { logLevels.Debug, "debug", color.Bit24(0, 128, 255, false).Sprintf, }, { logLevels.Trace, "trace", color.Bit24(128, 0, 255, false).Sprintf, }, } Levels = []string{ Off, Fatal, Error, Check, Warn, Info, Debug, Trace, } LogChanDisabled = atomic.NewBool(true) LogChan chan Entry )
Functions ¶
func Add ¶
Add adds a subsystem to the list of known subsystems and returns the string so it is nice and neat in the package logg.go file
func AddFilteredSubsystem ¶
func AddFilteredSubsystem(hl string) struct{}
AddFilteredSubsystem adds a new subsystem Name to the highlighted list
func AddHighlightedSubsystem ¶
func AddHighlightedSubsystem(hl string) struct{}
AddHighlightedSubsystem adds a new subsystem Name to the highlighted list
func AddLogChan ¶
func AddLogChan() (ch chan Entry)
AddLogChan adds a channel that log entries are sent to
func DirectionString ¶
DirectionString is a helper function that returns a string that represents the direction of a connection (inbound or outbound).
func FileExists ¶
func LoadHighlightedSubsystems ¶
func LoadHighlightedSubsystems() (o []string)
LoadHighlightedSubsystems returns a copy of the map of highlighted subsystems
func LoadSubsystemFilter ¶
func LoadSubsystemFilter() (o []string)
LoadSubsystemFilter returns a copy of the map of filtered subsystems
func SetLogLevel ¶
func SetLogLevel(l string)
SetLogLevel sets the log level via a string, which can be truncated down to one character, similar to nmcli's argument processor, as the first letter is unique. This could be used with a linter to make larger command sets.
func SetLogWriteToFile ¶
func SetLogWriter ¶
SetLogWriter atomically changes the log io.Writer interface
func StoreHighlightedSubsystems ¶
StoreHighlightedSubsystems sets the list of subsystems to highlight
func StoreSubsystemFilter ¶
func StoreSubsystemFilter(filter []string)
StoreSubsystemFilter sets the list of subsystems to filter
Types ¶
type LevelPrinter ¶
type LevelPrinter struct { // Ln prints lists of interfaces with spaces in between Ln func(a ...interface{}) // F prints like fmt.Println surrounded by log details F func(format string, a ...interface{}) // S prints a spew.Sdump for an interface slice S func(a ...interface{}) // C accepts a function so that the extra computation can be avoided if it is // not being viewed C func(closure func() string) // Chk is a shortcut for printing if there is an error, or returning true Chk func(e error) bool }
LevelPrinter defines a set of terminal printing primitives that output with extra data, time, log logLevelList, and code location