logger

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: MIT Imports: 5 Imported by: 0

README

logger

Go Reference

A reusable logger module for basic logging, written in Go.

Usage

Client
package main

import (
    "log"

    "github.com/aheeva/logger"
)

func main() {
    // Setup logger with a log level
    logger.SetLogLevel("TRACE")

    lvl := logger.GetLogLevel()
    log.Println("Log level: " + lvl)     

    logger.Trace("This is just a trace");            // Prints on stdout with a cyan colored text
    logger.Print("This is just a simple log");       // Prints on stdout with a white colored text
    logger.Warn("This is just a warning log");       // Prints on stdout with a yellow colored text
    logger.Success("This is just a success log");    // Prints on stdout with a green colored text
    logger.Error("This is just an error log");       // Prints on stdout with a red colored text
}
Output

sample.png

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(s string)

Error prints logs of type "ERROR"

func GetLogLevel

func GetLogLevel() int

GetLogLevel returns the set log level

func Print

func Print(s string)

Print prints logs of type "LOG"

func SetLogLevel added in v1.0.4

func SetLogLevel(level string)

SetLogLevel sets the log level

func Success added in v1.0.3

func Success(s string)

Print prints logs of type "SUCCESS"

func Trace

func Trace(s string)

Trace prints logs of type "TRACE"

func Warn

func Warn(s string)

Warn prints logs of type "WARN"

Types

This section is empty.

Jump to

Keyboard shortcuts

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