defaultlogger

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: MIT Imports: 2 Imported by: 15

README

default-logger

My Default Logger for GoLang projects

Installation

go get -u github.com/moisespsena-go/default-logger

Usage

package main

import "github.com/moisespsena-go/default-logger"

var log = defaultlogger.NewLogger("main")

func main() {
	log.Info("Message!")
}

Change Format

package pkg

import (
	"os"
	
	"github.com/moisespsena-go/default-logger"
	"github.com/op/go-logging"
)

func init() {
	defaultlogger.Format = logging.MustStringFormatter(
		`%{color}%{time:15:04:05.000} %{module} %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}`)
}

Change Backend

package pkg

import (
	"os"
	
	"github.com/moisespsena-go/default-logger"
	"github.com/op/go-logging"
)

func init() {
	defaultlogger.Backend = logging.NewLogBackend(os.Stderr, "", 0)
}

Thank You!

By Moises P. Sena

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Format = logging.MustStringFormatter(
	`%{time:2006-01-02 15:04:05.999 -07:00}%{color} %{pid} %{level:.4s} [%{module}]: %{message}%{color:reset}`,
)

Functions

func GetOrCreateLogger

func GetOrCreateLogger(module string) logging.Logger

Types

This section is empty.

Jump to

Keyboard shortcuts

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