logger

package
v0.0.0-...-e5836b3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: GPL-3.0 Imports: 7 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(message string, data any, args ...any)

func DebugDump

func DebugDump(obj interface{})

func GetApplication

func GetApplication() string

func Info

func Info(message string, args ...any)

func SetApplication

func SetApplication(application string)

func SetCollectionName

func SetCollectionName(collectionName string)

func SetDatabase

func SetDatabase(db *redisdb.RedisDB)

func SetLogLevel

func SetLogLevel(level LogLevel)

func Warn

func Warn(message string, args ...any)

Types

type HttpError

type HttpError struct {
	Status LogStatus  `json:"-"`
	Err    LogMessage `json:"error"`
}

func Error

func Error(status LogStatus, fields *[]string, message string, err error, data any) *HttpError

func (*HttpError) Error

func (e *HttpError) Error() string

type Log

type Log struct {
	Db             *redisdb.RedisDB
	Application    string
	CollectionName string
	LogLevel       LogLevel
}
var (
	Logger Log
)

type LogDocument

type LogDocument struct {
	ID          primitive.ObjectID `json:"_id" bson:"_id"`
	Application string             `json:"application"`
	Timestamp   time.Time          `json:"timestamp"`
	Message     *LogMessage        `json:"message"`
}

type LogLevel

type LogLevel uint8
const (
	LogLevelNone LogLevel = iota
	LogLevelError
	LogLevelWarning
	LogLevelInfo
	LogLevelDebug
)

type LogMessage

type LogMessage struct {
	Time    time.Time `json:"time"`
	App     string    `json:"app"`
	Type    string    `json:"type"`
	Fields  *[]string `json:"fields,omitempty"`
	Message string    `json:"message"`
	Data    *string   `json:"data,omitempty"`
}

type LogStatus

type LogStatus uint
const (
	LogStatusNone LogStatus = iota
	LogStatusNotFound
	LogStatusBadRequest
	LogStatusConflict
	LogStatusInternalServerError
	LogStatusUnauthorized
	LogStatusForbidden
)

type LogTypes

type LogTypes uint8
const (
	LogTypesError LogTypes = iota
	LogTypesWarn
	LogTypesInfo
	LogTypesDebug
)

Jump to

Keyboard shortcuts

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