Documentation ¶
Overview ¶
Package coco is a combination of utilities that make it easy to print logs in a readable way for those applications that use the command line. Its goal is to be simple and easy to understand, without extra complexities, in simple words, you get what you set
Index ¶
Constants ¶
const GlobalFormat = "[%s]: %s\n"
GlobalFormat used by all the levels and indicates how to display the level and its corresponding message
[SUCCESS]: This is an example of a success message following the GlobalFormat
Variables ¶
var ErrLevelAlreadyDefined = errors.New("the level name indicated is in use, please choose another one")
ErrLevelAlreadyDefined is an error message displayed when the user wants to create a new Level but the name selected already exists in the map
Functions ¶
This section is empty.
Types ¶
type Level ¶
type Level string
Level is a custom type created and exposed with the purpose to bring the user a clear way to create their own levels
const ( // Error commonly used to display messages that cannot be addressed by the application Error Level = "error" // Success commonly used to inform the user that the process has been finalized successfully Success Level = "success" // Warning commonly used to inform the user about an error but the application can continue regardless Warning Level = "warning" // Info commonly used for debugging purposes and hidden to the final user Info Level = "info" )
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log structs encapsulates the list of levels defined by default and new ones that might be created by the user
func (*Log) Error ¶
Error is an alias to the main Log function, which gives the user a quick way to use this Level
func (*Log) Info ¶
Info is an alias to the main Log function, which gives the user a quick way to use this Level
func (*Log) Log ¶
Log is the function that combines the settings defined in Options and the levels defined in Level in order to use a variety of alternatives for the particular uses of any application
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
Option is a public struct that brings the user the possibility to modify default configurations on each level. In addition, Option brings the possibility to create new levels
func Default ¶
func Default() *Option
Default is the proposal created by Coco to configure the default levels, based on regular considerations but open to any change the user wants to make
func (*Option) SetColor ¶
SetColor brings the user the possibility to change the color (color.Attribute) of a specific Level