/logging

Internal Log Wrapper for GO using ZAP

Primary LanguageGo

Package lists

Logger

The log package, it's wrap the Zap package and provides interface for logging in our microservices

How to integrate?

  1. Include the module in the project
  2. Create a new instance of the logger with following code below
package main

import (
	"github.com/RyaWcksn/logging/logger"
)

func main(){
	serviceName := "dev"
	env := "dev"
	logLevel := "debug"
	
	log := logger.New(serviceName, env, logLevel)
	
	log.Debug("Hello from log!")
}

Supported log level hierarchy are :

  • debug
  • info
  • warn
  • error
  • panic
  • fatal

Methods

This logger package contains with some following methods and the implementation :

For Debug method, if it's using development or stage env, the log will be debug, if else, the log will be info level Debug

log.Debug("This is debug level")

Info

log.Info("This is info level")

Warn

log.Warn("This is warn level")

Error

log.Error("This is error level")

Panic

log.Panic("This is panic level")

Fatal

log.Fatal("This is fatal level")

For Debugf method, if it's using development or stage env, the log will be debug, if else, the log will be info level Debugf

log.Debugf("This is %s level", "debugf")

Infof

log.Infof("This is %s level", "infof")

Warnf

log.Warnf("This is %s level", "warnf")

Errorf

log.Errorf("This is %s level", "errorf")

Panicf

log.Panic("This is %s level", "panicf")

Fatalf

log.Fatalf("This is %s level", "fatalf")