logger

package module
v0.0.0-...-967bce6 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2019 License: Apache-2.0 Imports: 6 Imported by: 3

README

emoji-logger

Codacy Badge Go Report Card GoDoc

Package logger is a custom logger package to output colorized emoji output to the standard output. The programmer should feel free to trace log as much of the code.

Nicely color-coded in development (when a TTY is attached, otherwise just plain text): alt text

alt text

Installation

To install emoji-logger package, you need to install Go and set your Go workspace first.

  1. Download and install it:
$ go get -u github.com/vaibhavsingh97/emoji-logger
  1. Import it in your code:
import "github.com/vaibhavsingh97/emoji-logger"

Example

package main

import (
    "fmt"

    logger "github.com/vaibhavsingh97/emoji-logger"
)

func main() {
    logger.Level = 10
    // Timestamp Disabled
    logger.TimeStamps = false
    // Color output enabled
    logger.Color = true

    err := fmt.Errorf("It's a new Error")

    logger.Debug("This is a lifeline for software engineers")
    logger.Info("This helps software engineers while running application in prod")
    logger.Warning("Something unusual happended, but application is still running")
    logger.Error("Error %v", err)
    // Note: this does **NOT** exit!
    logger.Critical("Something very bad happened, application should be stopped")
    logger.Success("Hooray!! Application ran successfully")
}

Issues

You can report the bugs at the issue tracker

License

Built with ♥ by Vaibhav Singh(@vaibhavsingh97) under Apache License 2.0

You can find a copy of the License at https://github.com/vaibhavsingh97/emoji-logger/blob/master/LICENSE

Documentation

Overview

Package logger is a custom logger package to output colorized emoji output to the standard output. The programmer should feel free to trace log as much of the code.

Index

Constants

View Source
const (
	CriticalEmoji = "🚑"
	DebugEmoji    = "🐞"
	InfoEmoji     = "🧐"
	SuccessEmoji  = "✅"
	ErrorEmoji    = "😱"
	WarningEmoji  = "⚠️"
)

This is the set of emoji definition.

Variables

View Source
var (
	// Level	Numeric value
	// SUCCESS	60
	// CRITICAL	50
	// ERROR	40
	// WARNING	30
	// INFO		20
	// DEBUG	10
	// NOTSET	0
	//
	//
	// Sets the threshold for the logger.
	// Logging messages which are less severe than level will be ignored.
	// The  default level is set to NOTSET (which causes all messages to be
	// processed).
	Level = 0
	// TimeStamps defines if the output has timestamp or not.
	// This is a global option and affects all methods.
	TimeStamps = true
	// Color defines if the output is colorized or not. It's dynamically set to
	// false or true based on the stdout's file descriptor referring to a
	// terminal or not. This is a global option and affects all methods.
	Color = false
	// BackgroundColor defines if the output has Background color or not.
	// It's dynamically set to false or true based on the stdout's file
	// descriptor referring to a terminal or not. This is a global option and
	// affects all methods.
	BackgroundColor = false
)

It contains configuration of logger.

Functions

func Critical

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

Critical formats according to a format specifier and writes to standard output.

func Debug

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

Debug formats according to a format specifier and writes to standard output.

func Error

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

Error formats according to a format specifier and writes to standard output.

func Info

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

Info formats according to a format specifier and writes to standard output.

func Success

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

Success formats according to a format specifier and writes to standard output.

func Warning

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

Warning formats according to a format specifier and writes to standard output.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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