Documentation ¶
Overview ¶
Simple package to get user input from terminal.
Index ¶
- Constants
- Variables
- func Aux(vars ...interface{})
- func Aux2(vars ...interface{})
- func Aux3(vars ...interface{})
- func Aux4(vars ...interface{})
- func BlockShutdown()
- func Close(filename string) (err error)
- func Debug(vars ...interface{})
- func Defer(closer interface{}) func() error
- func DisableExport(flag int)
- func DisableOutput(flag int)
- func EnableExport(flag int)
- func Err(vars ...interface{})
- func Exit(exit_code int)
- func Fatal(vars ...interface{})
- func File(l_file_flag int, filename string, max_size_mb uint, max_rotation uint) (err error)
- func Flash(vars ...interface{})
- func GetConfirm(prompt string) bool
- func GetInput(prompt string) string
- func GetSecret(prompt string) string
- func HideTS()
- func HookSyslog(syslog_writer SyslogWriter)
- func LTZ()
- func LocalDefer(closer func() error)
- func Log(vars ...interface{})
- func LogFileAppend(existing_logger int, flag int)
- func NeedAnswer(prompt string, request func(prompt string) string) (output string)
- func Notice(vars ...interface{})
- func PressEnter(prompt string)
- func SetFile(flag int, input io.Writer)
- func SetOutput(flag int, w io.Writer)
- func SetPrefix(logger int, prefix_str string)
- func SetSignals(sig ...os.Signal)
- func SetTimestamp(flag int, use_ts bool)
- func ShowTS()
- func SignalCallback(signal os.Signal, callback func() (continue_shutdown bool))
- func Stderr(vars ...interface{})
- func Stdout(vars ...interface{})
- func Trace(vars ...interface{})
- func UTC()
- func UnblockShutdown()
- func UnhookSyslog()
- func Warn(vars ...interface{})
- type SyslogWriter
Constants ¶
const ( INFO = 1 << iota // Log Information ERROR // Log Errors WARN // Log Warning NOTICE // Log Notices DEBUG // Debug Logging TRACE // Trace Logging FATAL // Fatal Logging AUX // Auxilary Log AUX2 // Auxilary Log AUX3 // Auxilary Log AUX4 // Auxilary Log )
const ( STD = INFO | ERROR | WARN | NOTICE | FATAL | AUX | AUX2 | AUX3 | AUX4 ALL = INFO | ERROR | WARN | NOTICE | FATAL | AUX | AUX2 | AUX3 | AUX4 | DEBUG | TRACE )
Standard Loggers, minus debug and trace.
Variables ¶
var ( FatalOnOutError = true // Fatal on Output logging error. FatalOnFileError = true // Fatal on log file or file rotation errors. FatalOnExportError = true // Fatal on export/syslog error. )
var None dummyWriter
False writer for discarding output.
var PleaseWait _loader
PleaseWait is a wait prompt to display between requests.
Functions ¶
func BlockShutdown ¶
func BlockShutdown()
Global wait group, allows running processes to finish up tasks before app shutdown
func Defer ¶
func Defer(closer interface{}) func() error
Adds a function to the global defer, function must take no arguments and either return nothing or return an error.
func Exit ¶
func Exit(exit_code int)
Intended to be a defer statement at the begining of main, but can be called at anytime with an exit code. Tries to catch a panic if possible and log it as a fatal error, then proceeds to send a signal to the global defer/shutdown handler
func File ¶
Opens a new log file for writing, max_size is threshold for rotation, max_rotation is number of previous logs to hold on to. Set max_size_mb to 0 to disable file rotation.
func Flash ¶
func Flash(vars ...interface{})
Don't log, write text to standard error which will be overwritten on the next output.
func LocalDefer ¶
func LocalDefer(closer func() error)
This is a way of removing the global defer and instead locally defering to the function.
func LogFileAppend ¶
Tacks an additional logger to an exising log file.
func NeedAnswer ¶
Loop until a non-blank answer is given
func SignalCallback ¶
Set a callback function(no arguments) to run after receiving a specific syscall, function returns true to continue shutdown process.