Coder Social home page Coder Social logo

bearatol / lg Goto Github PK

View Code? Open in Web Editor NEW
25.0 1.0 1.0 29 KB

โœ๐Ÿป A simple golang logger that extends the standard log package.

Home Page: http://github.com/bearatol/lg

License: MIT License

Go 99.78% Makefile 0.22%
go golang log logger logging console console-color console-log console-logger simple

lg's Introduction

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 all properties of logs

For example:

package main

import "github.com/bearatol/lg"

func main() {
    lg.GetLogger().OffColor()
    lg.GetLogger().OffPrefix()
    lg.GetLogger().OffDate()
    lg.GetLogger().OffTime()
    lg.GetLogger().OffShortFile()

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

//...

or

package main

import "github.com/bearatol/lg"

func init() {
    lg.GetLogger().OffColor()
    lg.GetLogger().OffPrefix()
    lg.GetLogger().OffDate()
    lg.GetLogger().OffTime()
    lg.GetLogger().OffShortFile()
}

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

//...

lg's People

Contributors

bearatol avatar nacknime-official avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.