logger

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

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

Go to latest
Published: Feb 10, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

logger

Ported from it's original location in the Kubicorn code base.

Rainbow logs


package main

import (
	"github.com/kris-nova/logger"
	"fmt"
	"os"
)


func main(){

	logger.Fabulous = true
	logger.Color = false
	logger.Level = 4

	err := fmt.Errorf("New error")

	logger.Always("This is always printed")

	logger.Success("Hooray a good thing happened!")

	logger.Info("we found an error: %v", err)

	logger.Debug("this is a useful message for software enigneers")

	logger.Warning("something bad happened but the software can still run")

	// Notice this does *NOT* exit!
	logger.Critical("the software should stop running, this is bad")

	// Now we have to exit
	os.Exit(123)
}

Simple golang logger

package main

import (
	"github.com/kris-nova/logger"
	"fmt"
	"os"
)


func main(){

	// Most Verbose
	//logger.Level = 4

	// Normal
	// No info or debug messages, only warnings and criticals
	logger.Level = 2

	// Off
	//logger.Level = 0

	err := fmt.Errorf("New error")
	logger.Info("we found an error: %v", err)

	logger.Debug("this is a useful message for software enigneers")

	logger.Warning("something bad happened but the software can still run")

	// Notice this does *NOT* exit!
	logger.Critical("the software should stop running, this is bad")

	// Now we have to exit
	os.Exit(123)
}

Documentation

Index

Constants

View Source
const (
	AlwaysLabel   = "✿"
	CriticalLabel = "✖"
	DebugLabel    = "▶"
	InfoLabel     = "ℹ"
	SuccessLabel  = "✔"
	WarningLabel  = "!"
)

Variables

View Source
var (
	Level              = 2
	Color              = true
	Fabulous           = false
	FabulousWriter     = lol.NewLolWriter()
	FabulousTrueWriter = lol.NewTruecolorLolWriter()
	TestMode           = false
	Timestamps         = true
)

Functions

func Always

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

func Critical

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

func Debug

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

func Info

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

func Success

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

func Warning

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

Types

type Logger

type Logger func(format string, a ...interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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