utils

package
v0.0.0-...-7bebcf8 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteToString

func ByteToString(b []byte) string

func HandlerWithoutAddSource

func HandlerWithoutAddSource(opts *slog.HandlerOptions)

HandlerWithoutAddSource is the type used to set AddSource to false

func Init_LoggerGFS

func Init_LoggerGFS(logFilePath string, writeLogs string, handlerOpts ...HandlerOptionsFunc) error

Init_LoggerGFS will handle the initialization of the logger and set it as the default

func MapToJSON

func MapToJSON(s any) []byte

func NewDefaultLogger

func NewDefaultLogger(w io.Writer, handlerOpts ...HandlerOptionsFunc) error

NewDefaultLogger to create, and define a new default logger

func NewLogger

func NewLogger(w io.Writer, handlerOpts ...HandlerOptionsFunc) (*slog.Logger, error)

NewDefaultLogger to create, and define a new returned logger

func StructToJSON

func StructToJSON(s any) []byte

func ValidMailAddress

func ValidMailAddress(address string) (string, bool)

ValidMailAddress will check the validity of an email address

Types

type HandlerOptionsFunc

type HandlerOptionsFunc func(*slog.HandlerOptions)

HandlerOptionsFunc is the type used to define optional handler options

func HandlerWithLevel

func HandlerWithLevel(l slog.Leveler) HandlerOptionsFunc

HandlerWithLevel is the type used to add an optional Leveler

func HandlerWithReplaceAttr

func HandlerWithReplaceAttr(att func(groups []string, a slog.Attr) slog.Attr) HandlerOptionsFunc

HandlerWithLevel is the type used to add an optional ReplaceAttr

type WriterGFS

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

LoggerGFS is a custom GFS logger

func NewWriterGFS

func NewWriterGFS(logFilePath string) *WriterGFS

NewWriterGFS returns a newly initialized WriterGFS struct pointers

func (WriterGFS) Write

func (l WriterGFS) Write(b []byte) (n int, err error)

WriterGFS implementation of the io.Write interface. It will log in the console and write the log on a file

Jump to

Keyboard shortcuts

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