Documentation ¶
Index ¶
Constants ¶
const EraseLineSequence = ansi.EraseEntireLine + "\r" + ansi.CursorUp1
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Formatter ¶
type Formatter interface { // Log sends a content to the logger, with the specified log level. Log(content LogContent, level loggers.LogLevel) }
Formatter will handle a LogContent message and dispatch it to the appropriate logger.
func NewConsoleFormatter ¶
NewConsoleFormatter creates a new Formatter that will dispatch messages to a logger.Console.
If static is set to true, the formatter will ignore dynamic content.
func NewJSONFormatter ¶
NewJSONFormatter creates a new Formatter that will dispatch messages to a logger.JSON.
type LogBase ¶
type LogBase interface { LogContent // SetStyle sets the style of the message. The style is only rendered with logger.ConsoleLogger. SetStyle(style lipgloss.Style) LogBase // SetChild sets a child LogContent to the message. SetChild(child LogContent) LogBase }
LogBase is a simple implementation of LogContent. It supports colored output using lipgloss.Style, and can contain a child LogContent.
type LogClear ¶
type LogClear interface { LogContent }
LogClear is a utility LogContent that clears the terminal screen on logger.ConsoleLogger instances. It does nothing on logger.JSONLogger instances.
type LogContent ¶
type LogContent interface { // RenderConsole returns a string representation of the log content, that can be printed in a logger.Console. RenderConsole() string // RenderJSON returns a serializable representation of the log content, that can be printed in a logger.JSON. RenderJSON() interface{} }
LogContent represents a special value, that can automatically be rendered in both logger.Console and logger.JSON.
type LogDiscoverGRPC ¶
type LogDiscoverGRPC interface { LogContent }
func NewDiscoverGRPC ¶
func NewDiscoverGRPC(services []grpc.ServiceDesc, port int) LogDiscoverGRPC
type LogDynamicContent ¶
type LogDynamicContent interface { LogContent // RenderConsoleDynamic is a special method, that will be called periodically by the logger to update the content. // It is up to the dynamic implementation to keep an internal running state. This method will be called everytime // the message should be updated. // // This method must be ignored once StopRunning has been called. RenderConsoleDynamic(renderer func(msg string)) LogDynamicContent // StopRunning stops the dynamic render execution. After triggering it, every call to RenderConsoleDynamic must be // ignored. StopRunning() LogDynamicContent }
LogDynamicContent allows to render real-time output when the logger supports it. It is currently only available for logger.Console.
type LogDynamicContentPure ¶
type LogDynamicContentPure interface { // RenderConsoleDynamic implements LogDynamicContent.RenderConsoleDynamic interface. RenderConsoleDynamic(renderer func(msg string)) LogDynamicContent // StopRunning implements LogDynamicContent.StopRunning interface. StopRunning() LogDynamicContent }
LogDynamicContentPure is a subset of LogDynamicContent implemented by the generic default implementation.
func NewAnimated ¶
func NewAnimated(renderer LogDynamicContent, fps time.Duration, update func()) LogDynamicContentPure
NewAnimated creates a new LogDynamicContentPure instance, that allows to render animated content.
type LogList ¶
type LogList interface { LogContent // Append adds a new string to the list. Append(content string) LogList // Nest adds a new LogContent to the list. Nest(content LogContent) LogList // SetEnumerator sets the list enumerator. SetEnumerator(enumerator list.Enumerator) LogList // SetIndenter sets the list indenter. SetIndenter(indenter list.Indenter) LogList // SetStyle sets the style of the list. SetStyle(style lipgloss.Style) LogList // SetItemStyle sets the style of the list items. SetItemStyle(style lipgloss.Style) LogList }
LogList is a utility LogContent that renders a list of LogContent instances.
type LogLoader ¶
type LogLoader interface { LogDynamicContent // SetDescription updates the main message of the loader. Each change to this value triggers a new log, under // static environments. SetDescription(description string) LogLoader // SetCompleted marks the loader as completed. It triggers a new log under static environments. Under dynamic // environments, the loader is stopped. SetCompleted() LogLoader // SetChild sets a child LogContent to the loader. Each change to this value triggers a new log, under // static environments. SetChild(child LogContent) LogLoader // SetError marks the loader as errored. It triggers a new log under static environments. Under dynamic // environments, the loader is stopped. SetError() LogLoader }
LogLoader renders a loader. Under dynamic environments, the loader is animated, as a single log. Otherwise, each update is rendered as a separate log.
type LogMigrationsList ¶
type LogMigrationsList interface { LogContent SetLastAppliedGroup(groupID int64) LogMigrationsList }
LogMigrationsList us used to log a list of postgres migrations, along with their statuses.
func NewMigrationsList ¶
func NewMigrationsList(migrations migrate.MigrationSlice) LogMigrationsList
NewMigrationsList creates a new LogMigrationsList instance.
type LogPlaceholder ¶
type LogPlaceholder interface { LogContent }
LogPlaceholder renders a special message for indicating a no-op.
func NewPlaceholder ¶
func NewPlaceholder(content string) LogPlaceholder
NewPlaceholder creates a new LogPlaceholder instance.
type LogSplit ¶
type LogSplit interface { LogContent // SetConsoleMessage sets a message that will only be rendered if the logger implements loggers.Console. SetConsoleMessage(content string) LogSplit // SetJSONMessage sets a message that will only be rendered if the logger implements loggers.JSON. SetJSONMessage(content interface{}) LogSplit // SetConsoleContent sets a LogContent that will only be rendered if the logger implements loggers.Console. SetConsoleContent(content LogContent) LogSplit // SetJSONContent sets a LogContent that will only be rendered if the logger implements loggers.JSON. SetJSONContent(content LogContent) LogSplit // SetConsoleRenderer sets a render function that will only be triggered if the logger implements loggers.Console. SetConsoleRenderer(content func() string) LogSplit // SetJSONRenderer sets a render function that will only be triggered if the logger implements loggers.JSON. SetJSONRenderer(content func() interface{}) LogSplit }
LogSplit allows to set specific logs format for console and JSON.
type LogTitle ¶
type LogTitle interface { LogContent // SetDescription sets the description of the title, that appears under it (inside the title block). SetDescription(description string) LogTitle // SetChild sets the child of the title, that will be rendered as a section (under the title block). SetChild(child LogContent) LogTitle }
LogTitle renders a title element.