Documentation
¶
Overview ¶
Package ui contains basic tools for interacting with a user. This includes generating informational and debugging messages. It also includes functions for controlling whether those messages are displayed or not.
Index ¶
- Constants
- Variables
- func Active(class int, mode bool) bool
- func ActiveLoggers() string
- func CurrentLogFile() string
- func IsActive(class int) bool
- func IsConsolePipe() bool
- func Log(class int, format string, args ...interface{})
- func LoggerByClass(class int) string
- func LoggerByName(loggerName string) int
- func LoggerNames() []string
- func OpenLogFile(userLogFileName string, withTimeStamp bool) error
- func Prompt(p string) string
- func PromptPassword(p string) string
- func PurgeLogs() int
- func RollOverLog()
- func SaveLastLog() error
- func Say(format string, args ...interface{})
- func Tail(count int, session int) []string
- func WriteLog(class int, format string, args ...interface{})
Constants ¶
const ( // DefaultTableFormat means use whatever the default is that may have been set // by the global option --output-type, etc. DefaultTableFormat = "default" // TextTableFormat indicates the output format should be human-readable text. TextFormat = "text" // JSONTableFormat indicates the output format should be machine-readable JSON. JSONFormat = "json" // JSONIndentedTableFormat indicates JSON output that is indented for readability. JSONIndentedFormat = "indented" JSONIndentPrefix = "" JSONIndentSpacer = " " NoSuchLogger = -1 )
Formatted output types for data more complex than individual messages, such as the format for tabular data output. Choices are "text", "json", "indented", or default which means whatever was set by the command line or profile.
const ( AppLogger = iota AuthLogger ByteCodeLogger CLILogger CompilerLogger DBLogger DebugLogger InfoLogger InternalLogger OptimizerLogger RestLogger ServerLogger SQLLogger SymbolLogger TableLogger TraceLogger TokenLogger UserLogger )
Classes of loggers go here. These are sequential integer values, and should match the order of the items in the loggers array below.
Variables ¶
var LogRetainCount = -1
LogRetainCount is the number of roll-over log versions to keep in the logging directory.
var LogTimeStampFormat string
LogTimeStampFormat stores the format string used to produce log messages, using the Go standard format string. You can override the default by creating a profile item called "ego.log.format".
var OutputFormat = TextFormat
OutputFormat is the default output format if not overridden by a global option or explicit call from the user.
var QuietMode = false
QuietMode determines if optional messaging is performed.
Functions ¶
func ActiveLoggers ¶
func ActiveLoggers() string
Return a comma-separated list of the active loggers.
func CurrentLogFile ¶
func CurrentLogFile() string
Return the path of the current log file being written to.
func IsActive ¶
Determine if a given logger is active. This is particularly useful when deciding if it's worth doing complex formatting operations.
func IsConsolePipe ¶
func IsConsolePipe() bool
IsConsolePipe detects if the console (stdin) is a pipe versus a real device. This is used to manage prompts, etc.
func Log ¶
Log displays a message if the selected log class is enabled. If the class is not active, no action is taken. Use WriteLog if you want to write a message to a logging class regardless of whether it is active or not.
func LoggerByName ¶
For a given logger name, find the class ID.
func LoggerNames ¶
func LoggerNames() []string
func OpenLogFile ¶
func Prompt ¶
Prompt prints a prompt string, and gets input from the console. The line endings are removed and the remainder of the input is returned as a string.
func PromptPassword ¶
PromptPassword prompts the user with a string prompt, and then allows the user to enter confidential information such as a password without it being echoed on the terminal. The value entered is returned as a string.
func RollOverLog ¶
func RollOverLog()
Roll over the open log. Close the current log, and rename it to include a timestamp of when it was created. Then create a new log file.
func SaveLastLog ¶
func SaveLastLog() error
Save the current (last) log file to the archive name with the timestamp of when the log was initialized.
func Say ¶
func Say(format string, args ...interface{})
Say displays a message to the user unless we are in "quiet" mode. If there are no arguments, the format string is output without further processing (that is, safe even if it contains formatting operators, as long as there are no arguments).
Note that the format string is tested to see if it is probably a localization string. If so, it is localized before output. If it was localized, and there is a single argument that is a proper map[string]interface{} object, then that is used for the formatting.
Types ¶
This section is empty.