relog

package module
v0.0.0-...-efc3b4a Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: MIT Imports: 4 Imported by: 2

README

relog

relog is a lightweight logging package built on top of logrus, designed to provide simple and colorful logging output with minimal setup.

Features

  • Simplified logging with colorized outputs.
  • Leverages the power of logrus without the need to import it elsewhere in your projects.
  • Provides package-specific logging to better identify the origin of log messages.

Installation

go get github.com/root4loot/relog

Usage

package main

import "github.com/root4loot/relog"

func main() {
    logger := relog.NewLogger("MyApp")

    logger.SetLevel(relog.DebugLevel)
	// logger.SetLevel(relog.InfoLevel)
	// logger.SetLevel(relog.WarnLevel)
	// logger.SetLevel(relog.ErrorLevel)
	// logger.SetLevel(relog.FatalLevel)
	// logger.SetLevel(relog.PanicLevel)

    logger.Debug("This is a debug message.")
    logger.Info("This is an informational message.")
    logger.Warn("This is a warning message.")
    logger.Error("This is an error message.")
}

For more examples, see example.go.

Setting Log Levels

Adjust the log level easily:

logger.SetLevel(relog.InfoLevel)

Available log levels:

  • DebugLevel Displays the most detailed logs.
  • InfoLevel Default log level; good for runtime info.
  • WarnLevel For non-critical warnings.
  • ErrorLevel For errors.
  • FatalLevel For fatal errors (will call os.Exit(1)).
  • PanicLevel Highest severity (will panic after logging).

License

MIT License. See LICENSE for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomFormatter

type CustomFormatter struct {
	// contains filtered or unexported fields
}

func (*CustomFormatter) Format

func (f *CustomFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format formats the log output

type Fields

type Fields logrus.Fields

type Level

type Level int
const (
	DebugLevel Level = iota
	InfoLevel
	WarnLevel
	ErrorLevel
	FatalLevel
	PanicLevel
)

func (Level) String

func (lvl Level) String() string

type Logger

type Logger struct {
	*logrus.Logger
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(packageName string) *Logger

func (*Logger) GetLevel

func (logger *Logger) GetLevel() Level

func (*Logger) SetLevel

func (logger *Logger) SetLevel(level Level)

SetLevel sets the logger level

func (*Logger) WithFields

func (logger *Logger) WithFields(fields Fields) *logrus.Entry

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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