yinlog

package module
v0.0.0-...-6ca4d0f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2023 License: MIT Imports: 10 Imported by: 3

README ¶

yinlog

Lightweight and glossy logger for Go.

license   go report card   go reference

NOTE: This package was created before the release of charmbracelet/log to provide a simple and glossy logger using Lip Gloss to style and colorize the output. It is not so useful now, I can reach the same results simply configuring log.

Default

Source Code

Full line example

Printer Options

Source Code

Printer Options example

ListLog

Source Code

List log example

🆓 License

yinlog is free and open-source software licensed under the MIT License.


Made with Charm.

Documentation ¶

Index ¶

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

This section is empty.

Types ¶

type Formatter ¶

type Formatter interface {
	Format(*LogEntry) string
}

Formatter is the interface defining the methods to be implemented by a printer.

type Level ¶

type Level int8

Level represents the level of severity.

const (
	NoLevel Level = iota
	DebugLevel
	FatalLevel
	ErrorLevel
	WarningLevel
	InfoLevel
	SuccessLevel
	ImportantLevel
	DefaultLevel
)

Log Levels.

func (Level) String ¶

func (l Level) String() string

String returns the log level as string.

type LogEntry ¶

type LogEntry struct {
	Logger  *Logger
	Level   Level
	Message string
	Entries []LogEntry
	// contains filtered or unexported fields
}

LogEntry represents a single log entry.

func NewListLogger ¶

func NewListLogger() *LogEntry

NewListLogger returns a new entry with `entries` set.

func NewLogEntry ¶

func NewLogEntry(logger *Logger) *LogEntry

NewLogEntry returns a new entry.

func (*LogEntry) Append ¶

func (entry *LogEntry) Append(level Level, msg string)

Append add an entry to the `entries`.

func (*LogEntry) Debug ¶

func (entry *LogEntry) Debug(msg string)

Debug level message.

func (*LogEntry) Debugf ¶

func (entry *LogEntry) Debugf(msg string, v ...interface{})

Debugf level formatted message.

func (*LogEntry) Error ¶

func (entry *LogEntry) Error(msg string)

Error level message.

func (*LogEntry) Errorf ¶

func (entry *LogEntry) Errorf(msg string, v ...interface{})

Errorf level formatted message.

func (*LogEntry) Fatal ¶

func (entry *LogEntry) Fatal(msg string)

Fatal level message.

func (*LogEntry) Fatalf ¶

func (entry *LogEntry) Fatalf(msg string, v ...interface{})

Fatalf level formatted message.

func (*LogEntry) Important ¶

func (entry *LogEntry) Important(msg string)

Important level message.

func (*LogEntry) Importantf ¶

func (entry *LogEntry) Importantf(msg string, v ...interface{})

Importantf level formatted message.

func (*LogEntry) Indent ¶

func (entry *LogEntry) Indent()

Indent add a string as prefix when indent list entries.

func (*LogEntry) Info ¶

func (entry *LogEntry) Info(msg string)

Info level message.

func (*LogEntry) Infof ¶

func (entry *LogEntry) Infof(msg string, v ...interface{})

Infof level formatted message.

func (*LogEntry) IsListLogger ¶

func (entry *LogEntry) IsListLogger() bool

IsListLogger returns true when ListLogger.

func (*LogEntry) Plain ¶

func (entry *LogEntry) Plain(msg string)

Plain level message.

func (*LogEntry) Plainf ¶

func (entry *LogEntry) Plainf(msg string, v ...interface{})

Plainf level formatted message.

func (*LogEntry) Plainln ¶

func (entry *LogEntry) Plainln()

Plainln prints a new empty line.

func (*LogEntry) Render ¶

func (entry *LogEntry) Render()

Render prints log entry when ListLogger.

func (*LogEntry) SetIndentChar ¶

func (entry *LogEntry) SetIndentChar(c string)

SetIndentChar sets the char used as prefix when indent list entries. Whitespace as default.

func (*LogEntry) SetIndentSize ¶

func (entry *LogEntry) SetIndentSize(size int)

SetIndentSize sets how many time the indent char has to be repeated when indent list entries.

func (*LogEntry) SetPrefix ¶

func (entry *LogEntry) SetPrefix(c string)

SetPrefix sets the char used as prefix char for entries. Whitespace as default.

func (*LogEntry) String ¶

func (entry *LogEntry) String() string

String returns the entry as string.

func (*LogEntry) Success ¶

func (entry *LogEntry) Success(msg string)

Success level message.

func (*LogEntry) Successf ¶

func (entry *LogEntry) Successf(msg string, v ...interface{})

Successf level formatted message.

func (*LogEntry) Title ¶

func (entry *LogEntry) Title(title string)

Title set the test to be used as title for ListLogger.

func (*LogEntry) Unindent ¶

func (entry *LogEntry) Unindent()

Unindent resets the indent size.

func (*LogEntry) Warning ¶

func (entry *LogEntry) Warning(msg string)

Warning level message.

func (*LogEntry) Warningf ¶

func (entry *LogEntry) Warningf(msg string, v ...interface{})

Warningf level formatted message.

type Logger ¶

type Logger struct {
	Printer Printer
	Level   Level
}

Logger represents a logger with configurable Printer and Level.

func New ¶

func New() *Logger

New returns a new logger.

func (*Logger) Debug ¶

func (l *Logger) Debug(msg string)

Debug level message.

func (*Logger) Debugf ¶

func (l *Logger) Debugf(msg string, v ...interface{})

Debugf level formatted message.

func (*Logger) Error ¶

func (l *Logger) Error(msg string)

Error level message.

func (*Logger) Errorf ¶

func (l *Logger) Errorf(msg string, v ...interface{})

Errorf level formatted message.

func (*Logger) Fatal ¶

func (l *Logger) Fatal(msg string)

Fatal level message.

func (*Logger) Fatalf ¶

func (l *Logger) Fatalf(msg string, v ...interface{})

Fatalf level formatted message.

func (*Logger) Important ¶

func (l *Logger) Important(msg string)

Important level message.

func (*Logger) Importantf ¶

func (l *Logger) Importantf(msg string, v ...interface{})

Importantf level formatted message.

func (*Logger) Info ¶

func (l *Logger) Info(msg string)

Info level message.

func (*Logger) Infof ¶

func (l *Logger) Infof(msg string, v ...interface{})

Infof level formatted message.

func (*Logger) Plain ¶

func (l *Logger) Plain(msg string)

Plain level message.

func (*Logger) Plainf ¶

func (l *Logger) Plainf(msg string, v ...interface{})

Plainf level formatted message.

func (*Logger) Plainln ¶

func (l *Logger) Plainln()

Plainln prints a new empty line.

func (*Logger) SetLevel ¶

func (l *Logger) SetLevel(level Level)

SetLevel sets the logger Level.

func (*Logger) SetPrinter ¶

func (l *Logger) SetPrinter(printer Printer)

SetPrinter set the logger Printer.

func (*Logger) Success ¶

func (l *Logger) Success(msg string)

Success level message.

func (*Logger) Successf ¶

func (l *Logger) Successf(msg string, v ...interface{})

Successf level formatted message.

func (*Logger) Warning ¶

func (l *Logger) Warning(msg string)

Warning level message.

func (*Logger) Warningf ¶

func (l *Logger) Warningf(msg string, v ...interface{})

Warningf level formatted message.

type Printer ¶

type Printer interface {
	Print(string)
	SetPrinterOptions(options *PrinterOptions)
	Formatter
}

Printer is the interface defining the methods to be implemented by a printer.

type PrinterOptions ¶

type PrinterOptions struct {
	Timestamp       bool
	TimestampFormat string
	Colors          bool
	Labels          bool
	Icons           bool
}

PrinterOptions sets stdout as printer.

type TextPrinter ¶

type TextPrinter struct {
	Writer  io.Writer
	Options *PrinterOptions
}

TextPrinter sets stdout as printer.

func (*TextPrinter) Format ¶

func (tp *TextPrinter) Format(entry *LogEntry) string

Format defines how the TextPrinter will format a log entry.

func (*TextPrinter) Print ¶

func (tp *TextPrinter) Print(msg string)

Print send the message string to the stdout.

func (*TextPrinter) SetPrinterOptions ¶

func (tp *TextPrinter) SetPrinterOptions(options *PrinterOptions)

SetPrinterOptions sets the printer options for TextPrinter.

Directories ¶

Path Synopsis
_examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL