colored_log

package module
v0.0.0-...-ee6e41a Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: MIT Imports: 5 Imported by: 0

README

Colored Log

🟥🟧🟨🟩🟦🟪 Colored logging in golang

Example

Code
import (
	log "github.com/urishabh12/colored_log"
)

func main() {
    log.Println("Default Log")
    log.Success("Success")
    log.Panic("Panic/Fatal Log")
}
Output

evio

GoDoc

Documentation

Index

Constants

View Source
const (
	Red    = "\033[31m"
	Green  = "\033[32m"
	Yellow = "\033[33m"
	Blue   = "\033[34m"
	Purple = "\033[35m"
	Cyan   = "\033[36m"
	White  = "\033[37m"
)

Variables

This section is empty.

Functions

func Fatal

func Fatal(a ...interface{})

Similar to log.Fatal Prints in error color

func Fatalf

func Fatalf(format string, v ...interface{})

Similar to log.Fatalf Prints in error color

func Fatalln

func Fatalln(a ...interface{})

Similar to log.Fataln Prints in error color

func Flags

func Flags() int

Flags returns the output flags for the standard logger. The flag bits are Ldate, Ltime, and so on.

func Output

func Output(calldepth int, s string) error

Similar to logger Output()

func Panic

func Panic(a ...interface{})

Similar to log.Panic Prints in error color

func Panicf

func Panicf(format string, v ...interface{})

Similar to log.Panicf Prints in error color

func Panicln

func Panicln(a ...interface{})

Similar to log.Panicln Prints in error color

func Prefix

func Prefix() string

Prefix returns the output prefix for the standard logger.

func Print

func Print(a ...interface{})

Prints to io.Writer Uses log.Print, prints in default color

func Printf

func Printf(format string, v ...interface{})

Prints to io.Writer with formated text Uses log.Printf, prints in default color

func Println

func Println(a ...interface{})

Prints to io.Writer with new line Uses log.Println, prints in default color

func SetFlags

func SetFlags(flag int)

Sets log flag to input

func SetOutput

func SetOutput(w io.Writer)

Sets outputs of all types of logs to input wirter

func SetPrefix

func SetPrefix(prefix string)

Sets prefix for all types of logger to input

func Success

func Success(a ...interface{})

Similar to Print Prints in success color

func Successf

func Successf(format string, v ...interface{})

Similar to Printf Prints in success color

func Successln

func Successln(a ...interface{})

Similar to Println Prints in success color

func Writer

func Writer() io.Writer

Writer returns the output destination for the standard logger.

Types

type ColoredLogger

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

func New

func New(out io.Writer, prefix string, flag int) *ColoredLogger

func NewColored

func NewColored(out io.Writer, prefix string, default_color string, success_color string, error_color string, flag int) *ColoredLogger

func (*ColoredLogger) Fatal

func (l *ColoredLogger) Fatal(a ...interface{})

func (*ColoredLogger) Fatalf

func (l *ColoredLogger) Fatalf(format string, v ...interface{})

func (*ColoredLogger) Fatalln

func (l *ColoredLogger) Fatalln(a ...interface{})

func (*ColoredLogger) Flags

func (l *ColoredLogger) Flags() int

func (*ColoredLogger) Output

func (l *ColoredLogger) Output(calldepth int, s string) error

func (*ColoredLogger) Panic

func (l *ColoredLogger) Panic(a ...interface{})

func (*ColoredLogger) Panicf

func (l *ColoredLogger) Panicf(format string, v ...interface{})

func (*ColoredLogger) Panicln

func (l *ColoredLogger) Panicln(a ...interface{})

func (*ColoredLogger) Prefix

func (l *ColoredLogger) Prefix() string

func (*ColoredLogger) Print

func (l *ColoredLogger) Print(a ...interface{})

func (*ColoredLogger) Printf

func (l *ColoredLogger) Printf(format string, v ...interface{})

func (*ColoredLogger) Println

func (l *ColoredLogger) Println(a ...interface{})

func (*ColoredLogger) SetFlags

func (l *ColoredLogger) SetFlags(i int)

Sets log flag to input

func (*ColoredLogger) SetOutput

func (l *ColoredLogger) SetOutput(w io.Writer)

Sets outputs of all types of logs to input wirter

func (*ColoredLogger) SetPrefix

func (l *ColoredLogger) SetPrefix(s string)

Sets prefix to input

func (*ColoredLogger) Success

func (l *ColoredLogger) Success(a ...interface{})

func (*ColoredLogger) Successf

func (l *ColoredLogger) Successf(format string, v ...interface{})

func (*ColoredLogger) Successln

func (l *ColoredLogger) Successln(a ...interface{})

func (*ColoredLogger) Writer

func (l *ColoredLogger) Writer() io.Writer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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