Documentation ¶
Index ¶
- func Close()
- func Debug(format string, v ...interface{})
- func DisableBorder()
- func DisableColor()
- func DisablePrefix()
- func Error(err error)
- func ErrorText(format string, v ...interface{})
- func Info(format string, v ...interface{})
- func SetOutput(dir string)
- func UsePrefix(prefix string)
- func Warn(format string, v ...interface{})
- type Console
- func (c *Console) Close()
- func (c *Console) Debug(format string, v ...interface{})
- func (c *Console) Disable()
- func (c *Console) DisableBorder()
- func (c *Console) DisableColor()
- func (c *Console) DisablePrefix()
- func (c *Console) Error(err error)
- func (c *Console) ErrorText(format string, v ...interface{})
- func (c *Console) Flush() error
- func (c *Console) Info(format string, v ...interface{})
- func (c *Console) SetLevel(level Level)
- func (c *Console) Use(opt ...Option)
- func (c *Console) Warn(format string, v ...interface{})
- type Level
- type Option
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
func Debug(format string, v ...interface{})
Debug prints debug level log.
Example ¶
DisableColor() colorConsole.useTestTime("2021-11-27") Debug("hello ketty")
Output: [DEBUG] 2021-11-27 hello ketty
func DisableBorder ¶
func DisableBorder()
DisableBorder prints log with borderless.
Example ¶
DisableBorder() DisableColor() colorConsole.useTestTime("2021-11-27") Info("hello ketty")
Output: [INFO] 2021-11-27 hello ketty
func DisableColor ¶
func DisableColor()
DisableColor sets the color flag as false, if it is, the Console won't print log with color.
func ErrorText ¶
func ErrorText(format string, v ...interface{})
ErrorText prints error level log.
Example ¶
DisableColor() DisablePrefix() DisableBorder() ErrorText("hello ketty")
Output: hello ketty
func Info ¶
func Info(format string, v ...interface{})
Info prints info level log.
Example ¶
DisableColor() colorConsole.useTestTime("2021-11-27") Info("hello ketty")
Output: [INFO] 2021-11-27 hello ketty
Types ¶
type Console ¶
type Console struct {
// contains filtered or unexported fields
}
Console is log printer which implements Logger.
func NewConsole ¶
NewConsole creates an instance of Console.
func (*Console) Debug ¶
Debug prints debug level log.
Example ¶
c := NewConsole() c.DisableColor() c.useTestTime("2021-11-27") c.Debug("hello ketty")
Output: [DEBUG] 2021-11-27┌──────────── [DEBUG] 2021-11-27│ hello ketty [DEBUG] 2021-11-27└────────────
func (*Console) DisableBorder ¶
func (c *Console) DisableBorder()
DisableBorder prints log with borderless.
Example ¶
c := NewConsole() c.DisableBorder() c.DisableColor() c.useTestTime("2021-11-27") c.Info("hello ketty")
Output: [INFO] 2021-11-27 hello ketty
func (*Console) DisableColor ¶
func (c *Console) DisableColor()
DisableColor sets the color flag as false, if it is, the Console won't print log with color.
func (*Console) DisablePrefix ¶
func (c *Console) DisablePrefix()
DisablePrefix prints log without prefix
Example ¶
c := NewConsole() c.DisableBorder() c.DisableColor() c.DisablePrefix() c.Info("hello ketty")
Output: hello ketty
func (*Console) ErrorText ¶
ErrorText prints error level log.
Example ¶
c := NewConsole() c.DisableColor() c.DisablePrefix() c.DisableBorder() c.ErrorText("hello ketty")
Output: hello ketty
func (*Console) Info ¶
Info prints info level log.
Example ¶
c := NewConsole() c.DisableColor() c.useTestTime("2021-11-27") c.Info("hello ketty")
Output: [INFO] 2021-11-27┌──────────── [INFO] 2021-11-27│ hello ketty [INFO] 2021-11-27└────────────
type Option ¶
type Option func(c *Console)
Option is an alias of the function with argument Console.
func WithOutputDir ¶
WithOutputDir sets an output file for Logger.
func WithTextOption ¶
WithTextOption returns an Option wrapped text.Option.