Documentation ¶
Overview ¶
Package message contains functions to print messages to the screen
Package message contains functions to print messages to the screen ¶
Package message provides a rich set of functions for displaying messages to the user.
Package message provides a rich set of functions for displaying messages to the user.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NewProgressSpinner = func(format string, a ...any) helpers.ProgressWriter { if activeSpinner != nil { activeSpinner.Updatef(format, a...) debugPrinter(2, "Active spinner already exists") return activeSpinner } var spinner *pterm.SpinnerPrinter if NoProgress { infof(format, a...) } else { text := pterm.Sprintf(format, a...) spinner, _ = pterm.DefaultSpinner. WithRemoveWhenDone(false). WithSequence(sequence...). Start(text) } activeSpinner = &Spinner{ spinner: spinner, termWidth: pterm.GetTerminalWidth(), } return activeSpinner }
NewProgressSpinner creates a new progress spinner.
var NoProgress bool
NoProgress sets whether the default spinners and progress bars should use fancy animations
var ( // SLog sets the default structured log handler for messages SLog = slog.New(MaruHandler{}) )
Functions ¶
func LogFileLocation ¶
func LogFileLocation() string
LogFileLocation returns the location of the log file.
Types ¶
type LogLevel ¶
type LogLevel int
LogLevel is the level of logging to display.
const ( // TraceLevel level. Effectively the same as Debug but with line numbers. // // NOTE: There currently is no Trace() function in the log/slog package. In // order to use this level, you must use message.SLog.Log() and specify the // level. Maru currently uses the Trace level specifically for adding line // numbers to logs from calls to message.SLog.Debug(). Because of this, // Trace is effectively the same as Debug but with line numbers. TraceLevel LogLevel = -8 // DebugLevel level. Usually only enabled when debugging. Very verbose logging. DebugLevel LogLevel = -4 // InfoLevel level. General operational entries about what's going on inside the // application. InfoLevel LogLevel = 0 // WarnLevel level. Non-critical entries that deserve eyes. WarnLevel LogLevel = 4 // ErrorLevel level. Errors only. ErrorLevel LogLevel = 8 )
type MaruHandler ¶
type MaruHandler struct{}
MaruHandler is a simple handler that implements the slog.Handler interface
func (MaruHandler) Enabled ¶
Enabled determines if the handler is enabled for the given level. This function is called for every log message and will compare the level of the message to the log level set (default is info). Log levels are defined in src/message/logging.go and match the levels used in the underlying log/slog package. Logs with a level below the set log level will be ignored.
Examples:
SetLogLevel(TraceLevel) // show everything, with file names and line numbers SetLogLevel(DebugLevel) // show everything SetLogLevel(InfoLevel) // show info and above (does not show debug logs) SetLogLevel(WarnLevel) // show warn and above (does not show debug/info logs) SetLogLevel(ErrorLevel) // show only errors (does not show debug/info/warn logs)
func (MaruHandler) Handle ¶
Handle prints the respective logging function in Maru This function ignores any key pairs passed through the record
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner is a wrapper around pterm.SpinnerPrinter.