gogger

package module
Version: v0.0.0-...-4a9f807 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2020 License: MIT Imports: 3 Imported by: 0

README

Gogger - The Go Logger

Gogger is a console logger designed for simplicity and great features at the same time! It has configurable color options for a (configurable) project name and the levels. The level options are Verbose (AKA Debug), Info, Warn, Error and Fatal!

Installation

Installation is simple, just use go get like any other package.

go get github.com/Jack-Gledhill/gogger

Example

Below is an example of how you'd use Gogger in most use-cases.

package main

import "github.com/Jack-Gledhill/gogger"

func main() {
    log := gogger.New("MyProject", gogger.USDateTimeFormat, true) // project name, datetime format, use colors?

    // Do something here...

    log.Verbose("Hey this is a verbose message, who'da thought?")
}

Documentation

See https://godoc.org/github.com/Jack-Gledhill/gogger for full documentation!

Documentation

Overview

Package gogger is a console logger designed for simplicity and great features at the same time!

Index

Constants

View Source
const (
	// VerboseLevel represents the level at which Verbose logs can be displayed.
	VerboseLevel int = 0
	// InfoLevel represents the level at which Info logs can be displayed.
	InfoLevel int = 1
	// WarnLevel represents the level at which Warn logs can be displayed.
	WarnLevel int = 2
	// ErrorLevel represents the level at which Error logs can be displayed.
	ErrorLevel int = 3
	// FatalLevel represents the level at which Fatal logs can be displayed.
	FatalLevel int = 4

	// UKDateTimeFormat represents the time in the UK standard format.
	UKDateTimeFormat string = "02-01-2006 15:04:05"
	// USDateTimeFormat represents the time in the US standard format.
	USDateTimeFormat string = "01-02-2006 15:04:05"
)

Variables

View Source
var (
	// ProjectNameColor is the color used for the project name in logs.
	ProjectNameColor = color.FgGreen

	// LevelColors is a list of github.com/faith/color color values to use for each level
	LevelColors = [5]color.Attribute{color.FgMagenta, color.FgCyan, color.FgYellow, color.FgRed, color.FgRed}
	// LevelStrings represents the strings used in logs to represent that particular level.
	LevelStrings [5]string = [5]string{"verbose", "info   ", "warn   ", "error  ", "fatal  "}
)

Functions

This section is empty.

Types

type GoggerLogger

type GoggerLogger struct {
	ProjectName string
	Level       int
	TimeFormat  string
	Colorful    bool
}

GoggerLogger is the logging handler used for printing messages to the console.

func New

func New(projectName string, timeFormat string, colorful bool) GoggerLogger

New initialises a new GoggerLogger.

func (*GoggerLogger) Error

func (g *GoggerLogger) Error(message string) bool

Error messages are used to represent an error that needs logging but was still handled.

func (*GoggerLogger) Errorf

func (g *GoggerLogger) Errorf(message string, formatOptions ...interface{}) bool

Errorf is like Error but with Sprintf.

func (*GoggerLogger) Fatal

func (g *GoggerLogger) Fatal(message string) bool

Fatal messages denote that something really bad happened and the program has shut down.

func (*GoggerLogger) Fatalf

func (g *GoggerLogger) Fatalf(message string, formatOptions ...interface{}) bool

Fatalf is like Fatal but with Sprintf.

func (*GoggerLogger) Info

func (g *GoggerLogger) Info(message string) bool

Info logs are at the default logging level and represent informative information without being too specific.

func (*GoggerLogger) Infof

func (g *GoggerLogger) Infof(message string, formatOptions ...interface{}) bool

Infof is like Info but with Sprintf.

func (*GoggerLogger) SetLevel

func (g *GoggerLogger) SetLevel(level int) error

SetLevel will change the current level of the GoggerLogger.

func (*GoggerLogger) Verbose

func (g *GoggerLogger) Verbose(message string) bool

Verbose messages are at the lowest log level and represent very detailed information.

func (*GoggerLogger) Verbosef

func (g *GoggerLogger) Verbosef(message string, formatOptions ...interface{}) bool

Verbosef is like Verbose but with Sprintf.

func (*GoggerLogger) Warn

func (g *GoggerLogger) Warn(message string) bool

Warn messages at used to represent something bad happening without it being catastrophic.

func (*GoggerLogger) Warnf

func (g *GoggerLogger) Warnf(message string, formatOptions ...interface{}) bool

Warnf is like Warn but with Sprintf.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL