Documentation ¶
Index ¶
- Constants
- Variables
- func Blue(data []byte) []byte
- func Cyan(data []byte) []byte
- func Gray(data []byte) []byte
- func Green(data []byte) []byte
- func Orange(data []byte) []byte
- func Purple(data []byte) []byte
- func Red(data []byte) []byte
- type Color
- type ColorLogger
- func (cb *ColorLogger) Append(data []byte)
- func (cb *ColorLogger) AppendSpace()
- func (cb *ColorLogger) AppendWithColor(data []byte, color Color)
- func (cb *ColorLogger) Blue()
- func (cb *ColorLogger) BrightOrange()
- func (cb *ColorLogger) Cyan()
- func (cb *ColorLogger) Gray()
- func (cb *ColorLogger) Green()
- func (cb *ColorLogger) NicePurple()
- func (cb *ColorLogger) Off()
- func (cb *ColorLogger) Orange()
- func (cb *ColorLogger) Purple()
- func (cb *ColorLogger) Red()
- func (cb *ColorLogger) White()
- func (cb *ColorLogger) WriteColor(color Color)
- type FancyHttpLog
- type FancyLogger
- type FdWriter
- type FormatLog
- type HttpLog
- func (h *HttpLog) ConnectMethod(a map[string]any, status int)
- func (h *HttpLog) DebugHeaders() bool
- func (h *HttpLog) DeleteMethod(a map[string]any, status int)
- func (h *HttpLog) GetMethod(a map[string]any, status int)
- func (h *HttpLog) HeadMethod(a map[string]any, status int)
- func (h *HttpLog) OptionsMethod(a map[string]any, status int)
- func (h *HttpLog) PostMethod(a map[string]any, status int)
- func (h *HttpLog) PutMethod(a map[string]any, status int)
- func (h *HttpLog) TraceMethod(a map[string]any, status int)
- func (h *HttpLog) WithHeaders() FancyHttpLog
- type Level
- type Logger
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) DebugMap(v map[string]interface{})
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) ErrorMap(v map[string]interface{})
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) Fatal(v ...interface{})
- func (l *Logger) FatalMap(v map[string]interface{})
- func (l *Logger) FatalMapWithCode(exit int, v map[string]interface{})
- func (l *Logger) FatalWithCode(exit int, v ...interface{})
- func (l *Logger) FatalWithCodef(format string, exit int, v ...interface{})
- func (l *Logger) Fatalf(format string, v ...interface{})
- func (l *Logger) Info(v ...interface{})
- func (l *Logger) InfoMap(v map[string]interface{})
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) IsDebug() bool
- func (l *Logger) IsQuiet() bool
- func (l *Logger) IsTrace() bool
- func (l *Logger) Log(prefix Prefix, a ...any)
- func (l *Logger) LogMap(prefix Prefix, a map[string]any)
- func (l *Logger) Logf(prefix Prefix, format string, a ...any)
- func (l *Logger) NoQuiet() FancyLogger
- func (l *Logger) Quiet() FancyLogger
- func (l *Logger) SetDefaultTimeFn(timestampFunc TimestampFunc)
- func (l *Logger) SetTimestampColor(color Color)
- func (l *Logger) Trace(v ...interface{})
- func (l *Logger) TraceMap(v map[string]interface{})
- func (l *Logger) Tracef(format string, v ...interface{})
- func (l *Logger) Warn(v ...interface{})
- func (l *Logger) WarnMap(v map[string]interface{})
- func (l *Logger) Warnf(format string, v ...any)
- func (l *Logger) WithColor() FancyLogger
- func (l *Logger) WithDebug() FancyLogger
- func (l *Logger) WithTimestamp() FancyLogger
- func (l *Logger) WithTrace() FancyLogger
- func (l *Logger) WithoutColor() FancyLogger
- func (l *Logger) WithoutDebug() FancyLogger
- func (l *Logger) WithoutTimestamp() FancyLogger
- func (l *Logger) WithoutTrace() FancyLogger
- type MappedLog
- type Methods
- type Prefix
- type PrefixLog
- type PrefixText
- type StandardLog
- type TimestampFunc
Constants ¶
const DepthSkip = 3
Variables ¶
var (
// Get retrieves a buffer from the pool, creating one if necessary.
Get = _pool.Get
)
var HttpPrefixes = map[Level]Prefix{ GetLevel: { Text: GetLevel, Color: ColorCyan, }, DeleteLevel: { Text: DeleteLevel, Color: ColorCyan, }, ConnectLevel: { Text: ConnectLevel, Color: ColorCyan, }, HeadLevel: { Text: HeadLevel, Color: ColorCyan, }, OptionsLevel: { Text: OptionsLevel, Color: ColorCyan, }, PostLevel: { Text: PostLevel, Color: ColorCyan, }, PutLevel: { Text: PutLevel, Color: ColorCyan, }, TraceLevel: { Text: TraceLevel, Color: ColorCyan, }, }
var Prefixes = map[Level]Prefix{ Fatal: { Text: Fatal, Color: ColorFatalRed, File: true, }, Error: { Text: Error, Color: ColorRed, }, Warn: { Text: Warn, Color: ColorOrange, }, Info: { Text: Info, Color: ColorGreen, }, Trace: { Text: Trace, Color: ColorCyan, File: true, }, Debug: { Text: Debug, Color: ColorPurple, }, }
Functions ¶
Types ¶
type Color ¶
type Color []byte
var ( ColorRed Color = []byte("\u001B[0;31m") ColorGreen Color = []byte("\u001B[0;32m") ColorOrange Color = []byte("\u001B[0;33m") ColorBlue Color = []byte("\u001B[0;34m") ColorPurple Color = []byte("\u001B[0;35m") ColorCyan Color = []byte("\u001B[0;36m") ColorGray Color = []byte("\u001B[0;37m") ColorFatalRed Color = []byte("\u001b[1m\u001b[31m\u001b[7m") ColorDarkOrange Color = []byte("\u001b[1m\u001b[38;5;202m") ColorBrightWhite Color = []byte("\u001b[1m\u001b[38;5;255m") ColorNicePurple Color = []byte("\u001b[1m\u001b[38;5;99m") )
func UncheckedCustomColor ¶
UncheckedCustomColor wrapper, this does not validate color
type ColorLogger ¶
func NewColorLogger ¶
func NewColorLogger() ColorLogger
func (*ColorLogger) AppendSpace ¶
func (cb *ColorLogger) AppendSpace()
func (*ColorLogger) AppendWithColor ¶
func (cb *ColorLogger) AppendWithColor(data []byte, color Color)
AppendWithColor byte slice to buffer
func (*ColorLogger) BrightOrange ¶
func (cb *ColorLogger) BrightOrange()
BrightOrange apply gray color to the data
func (*ColorLogger) NicePurple ¶
func (cb *ColorLogger) NicePurple()
NicePurple apply gray color to the data
func (*ColorLogger) WriteColor ¶
func (cb *ColorLogger) WriteColor(color Color)
WriteColor apply given color
type FancyHttpLog ¶ added in v0.0.13
type FancyHttpLog interface { FancyLogger Methods WithHeaders() FancyHttpLog DebugHeaders() bool }
func NewHttpLogger ¶ added in v0.0.11
func NewHttpLogger(out FdWriter) FancyHttpLog
func NewHttpLoggerWithError ¶ added in v0.0.11
func NewHttpLoggerWithError(out FdWriter, err FdWriter) FancyHttpLog
func NewHttpLoggerWithName ¶ added in v0.0.11
func NewHttpLoggerWithName(name string, out FdWriter) FancyHttpLog
func NewHttpLoggerWithNameAndError ¶ added in v0.0.11
func NewHttpLoggerWithNameAndError(name string, out FdWriter, err FdWriter) FancyHttpLog
type FancyLogger ¶ added in v0.0.11
type FancyLogger interface { StandardLog FormatLog MappedLog PrefixLog WithColor() FancyLogger WithoutColor() FancyLogger WithDebug() FancyLogger WithoutDebug() FancyLogger WithTrace() FancyLogger WithoutTrace() FancyLogger IsDebug() bool IsTrace() bool WithTimestamp() FancyLogger WithoutTimestamp() FancyLogger Quiet() FancyLogger NoQuiet() FancyLogger IsQuiet() bool // contains filtered or unexported methods }
type HttpLog ¶ added in v0.0.11
type HttpLog struct { FancyLogger // contains filtered or unexported fields }
func (*HttpLog) ConnectMethod ¶ added in v0.0.13
func (*HttpLog) DebugHeaders ¶ added in v0.0.13
func (*HttpLog) DeleteMethod ¶ added in v0.0.13
func (*HttpLog) HeadMethod ¶ added in v0.0.13
func (*HttpLog) OptionsMethod ¶ added in v0.0.13
func (*HttpLog) PostMethod ¶ added in v0.0.13
func (*HttpLog) TraceMethod ¶ added in v0.0.13
func (*HttpLog) WithHeaders ¶ added in v0.0.13
func (h *HttpLog) WithHeaders() FancyHttpLog
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger struct define the underlying storage for single logger
func New ¶
New returns new Logger instance with predefined writer output and automatically detect terminal coloring support
func NewWithError ¶
NewWithError returns new Logger instance with predefined writer output and automatically detect terminal coloring support. out would be something like os.Stdout and err would be something like os.Stderr
func NewWithName ¶
NewWithName {(name string out FdWriter) *Logger { returns new Logger instance with predefined writer output and automatically detect terminal coloring support
func NewWithNameAndError ¶
NewWithNameAndError {(name string out FdWriter) *Logger { returns new Logger instance with predefined writer output and automatically detect terminal coloring support
func (*Logger) Debug ¶
func (l *Logger) Debug(v ...interface{})
Debug print debug message to output if debug output enabled
func (*Logger) Fatal ¶
func (l *Logger) Fatal(v ...interface{})
Fatal print fatal message to output and quit the application with status 1
func (*Logger) FatalMapWithCode ¶
func (*Logger) FatalWithCode ¶
FatalWithCode print formatted fatal message to output and quit the application with status code provider
func (*Logger) FatalWithCodef ¶
FatalWithCodef print formatted fatal message to output and quit the application with status code provider
func (*Logger) Fatalf ¶
Fatalf print formatted fatal message to output and quit the application with status 1
func (*Logger) Info ¶
func (l *Logger) Info(v ...interface{})
Info print informational message to output
func (*Logger) SetDefaultTimeFn ¶
func (l *Logger) SetDefaultTimeFn(timestampFunc TimestampFunc)
SetDefaultTimeFn override the default timestamp producer
func (*Logger) SetTimestampColor ¶
SetTimestampColor override the default color for timestamps
func (*Logger) Trace ¶
func (l *Logger) Trace(v ...interface{})
Trace print trace message to output if debug output enabled
func (*Logger) WithColor ¶
func (l *Logger) WithColor() FancyLogger
WithColor explicitly turn on colorful features on the log
func (*Logger) WithDebug ¶
func (l *Logger) WithDebug() FancyLogger
WithDebug turn on debugging output on the log to reveal debug and trace level
func (*Logger) WithTimestamp ¶
func (l *Logger) WithTimestamp() FancyLogger
WithTimestamp turn on timestamp output on the log
func (*Logger) WithTrace ¶
func (l *Logger) WithTrace() FancyLogger
WithTrace turn on trace output on the log to reveal debug and trace level
func (*Logger) WithoutColor ¶
func (l *Logger) WithoutColor() FancyLogger
WithoutColor explicitly turn off colorful features on the log
func (*Logger) WithoutDebug ¶
func (l *Logger) WithoutDebug() FancyLogger
WithoutDebug turn off debugging output on the log
func (*Logger) WithoutTimestamp ¶
func (l *Logger) WithoutTimestamp() FancyLogger
WithoutTimestamp turn off timestamp output on the log
func (*Logger) WithoutTrace ¶
func (l *Logger) WithoutTrace() FancyLogger
WithoutTrace turn off trace output on the log
type Methods ¶ added in v0.0.11
type Methods interface { GetMethod(a map[string]any, status int) DeleteMethod(a map[string]any, status int) ConnectMethod(a map[string]any, status int) HeadMethod(a map[string]any, status int) OptionsMethod(a map[string]any, status int) PostMethod(a map[string]any, status int) PutMethod(a map[string]any, status int) TraceMethod(a map[string]any, status int) }
type Prefix ¶
Prefix struct define plain and color byte Text will prefix text to include in the log Color will be the color applied to the log File flag set to true will display code trace
type PrefixText ¶ added in v0.0.11
type PrefixText struct {
// contains filtered or unexported fields
}
PrefixText struct to hold the values of the prefixes to be used, and the tail size to add spaces to the end of the prefix