gologger: github.com/sadlil/gologger Index | Files

package gologger

import "github.com/sadlil/gologger"

Index

Package Files

color.go console.go es.go file.go gologger.go logger.go printer.go printerHandler.go

Constants

const (
    CONSOLE       string = "console"
    FILE          string = "file"
    ELASTICSEARCH string = "es"
    SimpleLog     string = "simple"
    ColoredLog    string = "color"
)

Variables

var NoColor = !isatty.IsTerminal(os.Stdout.Fd())

NoColor defines if the output is colorized or not. It's dynamically set to false or true based on the stdout's file descriptor referring to a terminal or not. This is a global option and affects all colors. For more control over each color block use the methods DisableColor() individually.

var Output = ansicolor.NewAnsiColorWriter(os.Stdout)

Output defines the standard output of the print functions. By default os.Stdout is used.

func Black Uses

func Black(format string, a ...interface{})

Black is an convenient helper function to print with black foreground. A newline is appended to format by default.

func BlackString Uses

func BlackString(format string, a ...interface{}) string

BlackString is an convenient helper function to return a string with black foreground.

func Blue Uses

func Blue(format string, a ...interface{})

Blue is an convenient helper function to print with blue foreground. A newline is appended to format by default.

func BlueString Uses

func BlueString(format string, a ...interface{}) string

BlueString is an convenient helper function to return a string with blue foreground.

func ConsolePrinter Uses

func ConsolePrinter(log LogInstance, packageName string, fileName string, lineNumber int, funcName string, time time.Time)

func Cyan Uses

func Cyan(format string, a ...interface{})

Cyan is an convenient helper function to print with cyan foreground. A newline is appended to format by default.

func CyanString Uses

func CyanString(format string, a ...interface{}) string

CyanString is an convenient helper function to return a string with cyan foreground.

func ESPrinter Uses

func ESPrinter(log LogInstance, packageName string, fileName string, lineNumber int, funcName string, time time.Time)

func FilePrinter Uses

func FilePrinter(log LogInstance, packageName string, fileName string, lineNumber int, funcName string, time time.Time)

func Green Uses

func Green(format string, a ...interface{})

Green is an convenient helper function to print with green foreground. A newline is appended to format by default.

func GreenString Uses

func GreenString(format string, a ...interface{}) string

GreenString is an convenient helper function to return a string with green foreground.

func Magenta Uses

func Magenta(format string, a ...interface{})

Magenta is an convenient helper function to print with magenta foreground. A newline is appended to format by default.

func MagentaString Uses

func MagentaString(format string, a ...interface{}) string

MagentaString is an convenient helper function to return a string with magenta foreground.

func Print Uses

func Print(log LogInstance, packageName string, fileName string, lineNumber int, funcName string, time time.Time)

func Red Uses

func Red(format string, a ...interface{})

Red is an convenient helper function to print with red foreground. A newline is appended to format by default.

func RedString Uses

func RedString(format string, a ...interface{}) string

RedString is an convenient helper function to return a string with red foreground.

func Unset Uses

func Unset()

Unset resets all escape attributes and clears the output. Usually should be called after Set().

func White Uses

func White(format string, a ...interface{})

White is an convenient helper function to print with white foreground. A newline is appended to format by default.

func WhiteString Uses

func WhiteString(format string, a ...interface{}) string

WhiteString is an convenient helper function to return a string with white foreground.

func Yellow Uses

func Yellow(format string, a ...interface{})

Yellow is an convenient helper function to print with yellow foreground. A newline is appended to format by default.

func YellowString Uses

func YellowString(format string, a ...interface{}) string

YellowString is an convenient helper function to return a string with yellow foreground.

type Attribute Uses

type Attribute int

Attribute defines a single SGR Code

const (
    Reset Attribute = iota
    Bold
    Faint
    Italic
    Underline
    BlinkSlow
    BlinkRapid
    ReverseVideo
    Concealed
    CrossedOut
)

Base attributes

const (
    FgBlack Attribute = iota + 30
    FgRed
    FgGreen
    FgYellow
    FgBlue
    FgMagenta
    FgCyan
    FgWhite
)

Foreground text colors

const (
    BgBlack Attribute = iota + 40
    BgRed
    BgGreen
    BgYellow
    BgBlue
    BgMagenta
    BgCyan
    BgWhite
)

Background text colors

type Color Uses

type Color struct {
    // contains filtered or unexported fields
}

Color defines a custom color object which is defined by SGR parameters.

func New Uses

func New(value ...Attribute) *Color

New returns a newly created color object.

func Set Uses

func Set(p ...Attribute) *Color

Set sets the given parameters immediately. It will change the color of output with the given SGR parameters until color.Unset() is called.

func (*Color) Add Uses

func (c *Color) Add(value ...Attribute) *Color

Add is used to chain SGR parameters. Use as many as parameters to combine and create custom color objects. Example: Add(color.FgRed, color.Underline).

func (*Color) DisableColor Uses

func (c *Color) DisableColor()

DisableColor disables the color output. Useful to not change any existing code and still being able to output. Can be used for flags like "--no-color". To enable back use EnableColor() method.

func (*Color) EnableColor Uses

func (c *Color) EnableColor()

EnableColor enables the color output. Use it in conjuction with DisableColor(). Otherwise this method has no side effects.

func (*Color) Equals Uses

func (c *Color) Equals(c2 *Color) bool

Equals returns a boolean value indicating whether two colors are equal.

func (*Color) Print Uses

func (c *Color) Print(a ...interface{}) (n int, err error)

Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered. This is the standard fmt.Print() method wrapped with the given color.

func (*Color) PrintFunc Uses

func (c *Color) PrintFunc() func(a ...interface{})

PrintFunc returns a new function that prints the passed arguments as colorized with color.Print().

func (*Color) Printf Uses

func (c *Color) Printf(format string, a ...interface{}) (n int, err error)

Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered. This is the standard fmt.Printf() method wrapped with the given color.

func (*Color) PrintfFunc Uses

func (c *Color) PrintfFunc() func(format string, a ...interface{})

PrintfFunc returns a new function that prints the passed arguments as colorized with color.Printf().

func (*Color) Println Uses

func (c *Color) Println(a ...interface{}) (n int, err error)

Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. This is the standard fmt.Print() method wrapped with the given color.

func (*Color) PrintlnFunc Uses

func (c *Color) PrintlnFunc() func(a ...interface{})

PrintlnFunc returns a new function that prints the passed arguments as colorized with color.Println().

func (*Color) Set Uses

func (c *Color) Set() *Color

Set sets the SGR sequence.

func (*Color) SprintFunc Uses

func (c *Color) SprintFunc() func(a ...interface{}) string

SprintFunc returns a new function that returns colorized strings for the given arguments with fmt.Sprint(). Useful to put into or mix into other string. Windows users should use this in conjuction with color.Output, example:

put := New(FgYellow).SprintFunc()
fmt.Fprintf(color.Output, "This is a %s", put("warning"))

func (*Color) SprintfFunc Uses

func (c *Color) SprintfFunc() func(format string, a ...interface{}) string

SprintfFunc returns a new function that returns colorized strings for the given arguments with fmt.Sprintf(). Useful to put into or mix into other string. Windows users should use this in conjuction with color.Output.

func (*Color) SprintlnFunc Uses

func (c *Color) SprintlnFunc() func(a ...interface{}) string

SprintlnFunc returns a new function that returns colorized strings for the given arguments with fmt.Sprintln(). Useful to put into or mix into other string. Windows users should use this in conjuction with color.Output.

type ElasticLog Uses

type ElasticLog struct {
    PackageName  string
    FileName     string
    FunctionName string
    LineNumber   int
    LogType      string
    Message      string
    Time         time.Time
}

type GoLogger Uses

type GoLogger struct {
    Logger
}

func GetLogger Uses

func GetLogger(selector ...string) GoLogger

func (GoLogger) Debug Uses

func (log GoLogger) Debug(message string)

func (GoLogger) Error Uses

func (log GoLogger) Error(message string)

func (GoLogger) Fatal Uses

func (log GoLogger) Fatal(message string)

func (GoLogger) Info Uses

func (log GoLogger) Info(message string)

func (GoLogger) Log Uses

func (log GoLogger) Log(message string)

func (GoLogger) Message Uses

func (log GoLogger) Message(message string)

func (GoLogger) ReplaceMessage Uses

func (log GoLogger) ReplaceMessage(message string)

func (GoLogger) Warn Uses

func (log GoLogger) Warn(message string)

type LogInstance Uses

type LogInstance struct {
    LogType    string
    Message    string
    LoggerInit Logger
}

type Logger Uses

type Logger struct {
    PrinterType string
    Location    string
}

Package gologger imports 10 packages (graph). Updated 2018-02-02. Refresh now. Tools for package owners.