logging

package
v0.0.0-...-a36e7e9 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category string
const (
	General         Category = "General"
	Internal        Category = "Internal"
	Database        Category = "Database"
	Validation      Category = "Validation"
	RequestResponse Category = "RequestResponse"
	Io              Category = "Io"
)

type ExtraKey

type ExtraKey string
const (
	AppName       ExtraKey = "AppName"
	LoggerName    ExtraKey = "Logger"
	Service       ExtraKey = "Service"
	UserId        ExtraKey = "UserId"
	TraceId       ExtraKey = "TraceId"
	ClientIp      ExtraKey = "ClientIp"
	HostIp        ExtraKey = "HostIp"
	Method        ExtraKey = "Method"
	StatusCode    ExtraKey = "StatusCode"
	BodySize      ExtraKey = "BodySize"
	Path          ExtraKey = "Path"
	Latency       ExtraKey = "Latency"
	RequestBody   ExtraKey = "RequestBody"
	RequestHeader ExtraKey = "RequestHeader"
	ResponseBody  ExtraKey = "ResponseBody"
	ErrorMessage  ExtraKey = "ErrorMessage"
)

type Logger

type Logger interface {
	Init(cfg *config.Config)

	Debug(cat Category, sub SubCategory, msg string, extra map[ExtraKey]interface{})
	Debugf(template string, args ...interface{})

	Info(cat Category, sub SubCategory, msg string, extra map[ExtraKey]interface{})
	Infof(template string, args ...interface{})

	Warn(cat Category, sub SubCategory, msg string, extra map[ExtraKey]interface{})
	Warnf(template string, args ...interface{})

	Error(cat Category, sub SubCategory, msg string, extra map[ExtraKey]interface{})
	Errorf(template string, args ...interface{})

	Fatal(cat Category, sub SubCategory, msg string, extra map[ExtraKey]interface{})
	Fatalf(template string, args ...interface{})
}

func NewLogger

func NewLogger(cfg *config.Config) Logger

type SubCategory

type SubCategory string
const (
	// General
	Startup         SubCategory = "Startup"
	ExternalService SubCategory = "ExternalService"

	// Database
	Migration       SubCategory = "Migration"
	Select          SubCategory = "Select"
	DatabaseTimeout SubCategory = "DatabaseTimeout"
	Rollback        SubCategory = "Rollback"
	Update          SubCategory = "Update"
	Delete          SubCategory = "Delete"
	Insert          SubCategory = "Insert"

	//validation
	QuestionnaireValidationFailed SubCategory = "QuestionnaireValidationFailed"

	UserNotFound          SubCategory = "UserNotFound"
	FailedToGenerateToken SubCategory = "FailedToGenerateToken"

	Api                         SubCategory = "Api"
	HashPassword                SubCategory = "HashPassword"
	UserNotAuthorized           SubCategory = "UserNotAuthorized"
	DefaultRoleNotFound         SubCategory = "DefaultRoleNotFound"
	FailedToCreateUser          SubCategory = "FailedToCreateUser"
	FailedToGetUsers            SubCategory = "FailedToGetUsers"
	FailedToGetUserCount        SubCategory = "FailedToGetUserCount"
	FailedToGetRole             SubCategory = "FailedToGetRole"
	FailedConvertDto            SubCategory = "FailedConvertDto"
	RecoverError                SubCategory = "Recover Error"
	FailedToGetParticipation    SubCategory = "FailedToGetParticipation"
	FailedToCreateParticipation SubCategory = "FailedToCreateParticipation"
	FailedToUpdateUser          SubCategory = "FailedToUpdateUser"
	FailedToParseDate           SubCategory = "FailedToParseDate"
	FailedToGetPermissions      SubCategory = "FailedToGetPermissions"
	FailedToSendNotify          SubCategory = "FailedToSendNotify"
	FailedToGetNotifications    SubCategory = "FailedToGetNotifications"
	FailedToSeenNotifications   SubCategory = "FailedToSeenNotifications"
)

Jump to

Keyboard shortcuts

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