MindorksOpenSource / Go-Log

A Go logger package which provides utility on top of Go's normal Log package.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go-Log

Go Report Card

Go-Log is a utility log package built to customize the Go's normal log package. Prominent features are

  • Tag the logs into debug and error variant.
  • Add/Remove Timestamp to logs
  • Get the calling function details in logs
  • Synchronized with mutex locks to handle multiple logging

Install

go get github.com/MindorksOpenSource/Go-Log

Import

import (
	"github.com/MindorksOpenSource/Go-Log"
)

Examples

1. GoLog Debug

func main() {
	golog.D("A basic primitive debug log.")
}

This golog prints the message without any extra information like:

$ A basic primitive debug log.

2. GoLog Error

func main() {
	golog.E("This a basic primitive error log.")
}

This golog prints the message while tagging it as an ERROR like:

$ [ERROR] This a basic primitive error log.

Configuration (Additional Information)

// Adds time to the log
golog.ConfigureTimer()
// Adds the calling function path to log
golog.ConfigureCallingFunction()

3. GoLog Debug/Error with Time

func main() {
	golog.ConfigureTimer()
	golog.D("A debug log with time")
}

This golog prints the message with its timestamp like:

$ 2018/10/29 15:52:24  A debug log with time

4. GoLog Debug/Error with CallingFunction

func main() {
	golog.ConfigureCallingFunction()
	golog.D("A debug log with calling function")
}

This golog prints the message with its timestamp like:

$ [main.main] A debug log with calling function

You can use both the configurations together also. Go gophers!

Contributor

Yashish Dua

Show some ❤️

GitHub stars GitHub forks GitHub watchers GitHub followers
Twitter Follow

About

A Go logger package which provides utility on top of Go's normal Log package.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Go 100.0%