logrz

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

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

Go to latest
Published: Nov 9, 2018 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

logrz

An easy way to log data to terminal in go

Install

go get github.com/Sata51/logrz

Usage

import (
	"github.com/Sata51/logrz"
)

func main() {
	logrz.T("Start!")
	//[ 14:57:34.183 ][ TRACE ][ logrz.TestLogger ] > Start! +52.391µs
	logrz.D("Start!")
	//[ 14:57:34.184 ][ DEBUG ][ logrz.TestLogger ] > Start! +228.062µs
	logrz.I("Start!")
	//[ 14:57:34.184 ][ INFO  ][ logrz.TestLogger ] > Start! +9.855µs
	logrz.W("Start!")
	//[ 14:57:34.184 ][ WARN  ][ logrz.TestLogger ] > Start! +13.144µs
	logrz.E("Start!")
	//[ 14:57:34.184 ][ ERROR ][ logrz.TestLogger ] > Start! +7.501µs
	logrz.F("Start!")
	//[ 14:57:34.184 ][ FATAL ][ logrz.TestLogger ] > Start! +7.206µs
	logrz.P("Start!")
	//[ 14:57:34.184 ][ PANIC ][ logrz.TestLogger ] > Start! +7.263µs

	//Set minimum log level to be print
	//Log level are sorted from Trace > Debug > Info > Warning > Error > Fatal > Panic
	logrz.SetLevel(logrz.ErrorLevel)

	//Disable log color
	logrs.DisableColor(bool)

	//Force the entire line to be colorized
	logrz.ForceFullColor(bool)
}

Documentation

Index

Constants

This section is empty.

Variables

AllLevels A constant exposing all logging levels

Functions

func D

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

D generate a debug log format

func DisableColor

func DisableColor(set bool)

DisableColor allow user to remove log color

func E

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

E generate an error log format

func F

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

F generate a fatal log format

func ForceFullColor

func ForceFullColor(set bool)

ForceFullColor allow user to force color on the entire log

func I

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

I generate an info log format

func P

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

P generate a panic log format

func SetLevel

func SetLevel(level Level)

SetLevel allow user to personalize logging level

func T

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

T generate a trace log format

func W

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

W generate a warn log format

Types

type Level

type Level uint32

Level type

const (
	// PanicLevel level, highest level of severity. Logs and then calls panic with the
	// message passed to Debug, Info, ...
	PanicLevel Level = iota //Handle auto incrementation for interger comparison
	// FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the
	// logging level is set to Panic.
	FatalLevel
	// ErrorLevel level. Logs. Used for errors that should definitely be noted.
	// Commonly used for hooks to send errors to an error tracking service.
	ErrorLevel
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel
	// InfoLevel level. General operational entries about what's going on inside the
	// application.
	InfoLevel
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel
	TraceLevel
)

These are the different logging levels. You can set the logging level to log on your instance of logger, obtained with `logrz.New()`.

func ParseLevel

func ParseLevel(lvl string) (Level, error)

ParseLevel takes a string level and returns the logrz log level constant.

func (Level) String

func (level Level) String() string

Convert the Level to a string. E.g. PanicLevel becomes "panic".

type LogComposition

type LogComposition struct {
	Time     string
	Level    Level
	Details  string
	Interval string
	Format   string
}

LogComposition log informations

Jump to

Keyboard shortcuts

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