notifyme

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

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

Go to latest
Published: Jul 15, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

README

NotifyMe Logger Package

The NotifyMe package is a robust and flexible logging library for Go applications. It provides various log levels and supports logging to different destinations, making it ideal for both development and production environments.

Features

  • Multiple Log Levels: Supports Info, Warn, Error, and Critical log levels.
  • Configurable Output: Log messages to standard output or a specified file.
  • Concurrency Safe: Ensures thread-safe logging operations.
  • Environment Configurable: Set log levels using environment variables.
  • Formatted Messages: Allows context and arguments for detailed log messages.
  • Easy Integration: Simple API for logging messages based on their severity.

Installation

To install the NotifyMe package, use the following command:

go get github.com/AmosSParker/NotifyMe

Documentation

Index

Constants

View Source
const (
	LevelInfo = iota
	LevelWarn
	LevelError
	LevelCritical
)

Log levels constants

Variables

This section is empty.

Functions

func InitFromEnv

func InitFromEnv()

InitFromEnv sets the log level based on an environment variable

func InitializeGlobalLogger

func InitializeGlobalLogger(level int, output ...string)

InitializeGlobalLogger creates and initializes the global logger instance

func Notify

func Notify(messageType string, message string, context ...interface{})

Notify handles logging based on the message type

func SetLevel

func SetLevel(level int)

SetLevel sets the global log level

Types

type Logger

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

Logger struct holds different loggers for various log levels

func GetGlobalLogger

func GetGlobalLogger() *Logger

GetGlobalLogger returns the global logger instance

func NewLogger

func NewLogger(level int, output ...string) *Logger

NewLogger creates and returns a new Logger instance

func (*Logger) Log

func (l *Logger) Log(level int, message string, optionalParams ...interface{})

Log logs a message with the given log level

func (*Logger) MarshalJSON

func (l *Logger) MarshalJSON() ([]byte, error)

func (*Logger) UnmarshalJSON

func (l *Logger) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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