lg

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 4 Imported by: 6

README

A simple logger for golang

GoDoc Build Status Go Report Card

A simple extension of the standard "log" library to minimize effort, code and ease of use

lg

The logger uses the standard go "log" package. Allows you to install and use expanded information (prefix, date and time, file and line) without cluttering up with unnecessary code. It also colors text on Linux and OS X for better reading of logs.

Install

go get -u github.com/bearatol/lg

Examples

package main

import (
	"github.com/bearatol/lg"
)

func main() {
	testArray := [...]int{1, 2, 3, 4, 5}

	// Info
	lg.Info("test text", testArray)
	lg.Infoln("test text", testArray)
	lg.Infof("some values: %s, %v", "test text", testArray)

	// Debug
	lg.Debug("test text", testArray)
	lg.Debugln("test text", testArray)
	lg.Debugf("some values: %s, %v", "test text", testArray)

	// Trace
	lg.Trace("test text", testArray)
	lg.Traceln("test text", testArray)
	lg.Tracef("some values: %s, %v", "test text", testArray)

	// Warning
	lg.Warn("test text", testArray)
	lg.Warnln("test text", testArray)
	lg.Warnf("some values: %s, %v", "test text", testArray)

	// Error
	lg.Error("test text", testArray)
	lg.Errorln("test text", testArray)
	lg.Errorf("some values: %s, %v", "test text", testArray)

	// Fatal
	lg.Fatal("test text", testArray)
	lg.Fatalln("test text", testArray)
	lg.Fatalf("some values: %s, %v", "test text", testArray)

	// Panic
	lg.Panic("test text", testArray)
	lg.Panicln("test text", testArray)
	lg.Panicf("some values: %s, %v", "test text", testArray)
}
You can turn off the color of logs

For example:

package main

import "github.com/bearatol/lg"

func main() {
    lg.GetLogger().OffColor()

    lg.Info("Hello, world!")
}

//...

or

package main

import "github.com/bearatol/lg"

func init() {
    lg.GetLogger().OffColor()
}

func main() {
    lg.Info("Hello, world!")
}

//...

Documentation

Overview

Сreated a new structure based on the logger structure of the standard Lg package.

Modification of the standard Lg package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{}) error

debug functions

func Debugf

func Debugf(format string, v ...interface{}) error

func Debugln

func Debugln(v ...interface{}) error

func Error

func Error(v ...interface{}) error

error functions

func Errorf

func Errorf(format string, v ...interface{}) error

func Errorln

func Errorln(v ...interface{}) error

func Fatal

func Fatal(v ...interface{}) error

fatal functions

func Fatalf

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

func Fatalln

func Fatalln(v ...interface{}) error

func GetLogger

func GetLogger() *logEnd

func Info

func Info(v ...interface{}) error

info functions

func Infof

func Infof(format string, v ...interface{}) error

func Infoln

func Infoln(v ...interface{}) error

func Panic

func Panic(v ...interface{}) error

panic functions

func Panicf

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

func Panicln

func Panicln(v ...interface{}) error

func Trace

func Trace(v ...interface{}) error

trace functions

func Tracef

func Tracef(format string, v ...interface{}) error

func Traceln

func Traceln(v ...interface{}) error

func Warn

func Warn(v ...interface{}) error

warning functions

func Warnf

func Warnf(format string, v ...interface{}) error

func Warnln

func Warnln(v ...interface{}) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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