Categorygithub.com/itrepablik/itrlog
modulepackage
1.0.3
Repository: https://github.com/itrepablik/itrlog.git
Documentation: pkg.go.dev

# README

ITRLog

The simplified usage of Zap and Lumberjack logging systems in Go for easier usage of the library.

Installation

go get -u github.com/itrepablik/itrlog

Usage

This is how you can use the simplified initializations for Zap and Lumberjack logging libraries.

package main

import (
	"github.com/itrepablik/itrlog"
)

func init() {
	// Custom settings to initialize the itrlog.
	itrlog.SetLogInit(50, 90, "logs", "test_log_")
}

func main() {
	// Basic logging message
	itrlog.Info("basic info log output...")
	itrlog.Error("basic error log output...")
	itrlog.Warn("basic warning log output...")
	itrlog.Debug("basic debug log output...")
	
	// Structured context as loosely typed key-value pairs.
	itrlog.Infow("New User", "username", "admin", "email", "[email protected]", "log_time", time.Now().Format(itrlog.LogTimeFormat))
	itrlog.Errorw("New User", "username", "admin", "email", "[email protected]", "log_time", time.Now().Format(itrlog.LogTimeFormat))
	itrlog.Warnw("New User", "username", "admin", "email", "[email protected]", "log_time", time.Now().Format(itrlog.LogTimeFormat))
	itrlog.Debugw("New User", "username", "admin", "email", "[email protected]", "log_time", time.Now().Format(itrlog.LogTimeFormat))
}

It will auto-create the logs folder in the root directory of your project, but, of course, it's up to you which directory to point your log files and the test_log_ is the initial log filename. The logging output it's a JSON format for easy integration with any of your existing software to keep track of the logs information.

Subscribe to Maharlikans Code Youtube Channel:

Please consider subscribing to my Youtube Channel to recognize my work on this package. Thank you for your support! https://www.youtube.com/channel/UCdAVUmldU9Jn2VntuQChHqQ/

License

Code is distributed under MIT license, feel free to use it in your proprietary projects as well.

# Functions

Debug uses fmt.Sprint to construct and log a message.
Debugf uses fmt.Sprintf to log a templated message.
Debugw logs a message with some additional context.
DPanic uses fmt.Sprint to construct and log a message.
DPanicf uses fmt.Sprintf to log a templated message.
DPanicw logs a message with some additional context.
Error uses fmt.Sprint to construct and log a message.
Errorf uses fmt.Sprintf to log a templated message.
Errorw logs a message with some additional context.
Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.
Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.
Fatalw logs a message with some additional context, then calls os.Exit.
Info uses fmt.Sprint to construct and log a message.
Infof uses fmt.Sprintf to log a templated message.
Infow logs a message with some additional context.
InitLog initialize the zap and lumberjack logger library.
Panic uses fmt.Sprint to construct and log a message, then panics.
Panicf uses fmt.Sprintf to log a templated message, then panics.
Panicw logs a message with some additional context, then panics.
SetLogInit sets the custom log requirement to initialize the itr logger.
Warn uses fmt.Sprint to construct and log a message.
Warnf uses fmt.Sprintf to log a templated message.
Warnw logs a message with some additional context.

# Constants

LogTimeFormat formats the event timestamp.

# Structs

ITRLogger contains the necessary information to initialize the required parameters for the itrlog package.