logger

package
v0.0.0-...-fd201ba Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapToZapParams

func MapToZapParams(keys map[ExtraKey]interface{}) []interface{}

func PrepareLogKeys

func PrepareLogKeys(cat Category, sub SubCategory, extra map[ExtraKey]interface{}) []interface{}

Types

type Category

type Category string
const (
	General         Category = "General"
	Profile         Category = "Profile"
	Router          Category = "Router"
	Internal        Category = "Internal"
	Database        Category = "Database"
	Cache           Category = "Cache"
	Validation      Category = "Validation"
	RequestResponse Category = "RequestResponse"
	Prometheus      Category = "Prometheus"
	JWT             Category = "JWT"
	Authorization   Category = "Authorization"
	Notification    Category = "Notification"
	UserManagement  Category = "UserManagement"
	Twilio          Category = "Twilio"
	Vonage          Category = "Vonage"
	SendGrid        Category = "SendGrid"
	Email           Category = "Email"
	Slack           Category = "Slack"
	Google          Category = "Google"
	Facebook        Category = "Facebook"
	Apple           Category = "Apple"
	Queue           Category = "Queue"
	Minio           Category = "Minio"
	TOTP            Category = "TOTP"
)

type ExtraKey

type ExtraKey string
const (
	ClientIp         ExtraKey = "ClientIp"
	ListeningAddress ExtraKey = "ListeningAddress"
	Method           ExtraKey = "Method"
	StatusCode       ExtraKey = "StatusCode"
	BodySize         ExtraKey = "BodySize"
	Path             ExtraKey = "Path"
	Latency          ExtraKey = "Latency"
	Body             ExtraKey = "Body"
	ErrorMessages    ExtraKey = "ErrorMessages"
	Headers          ExtraKey = "Headers"
	RequestBody      ExtraKey = "RequestBody"
	ResponseBody     ExtraKey = "ResponseBody"
	ErrorMessage     ExtraKey = "ErrorMessage"

	SelectDBArg ExtraKey = "SelectDBArg"
	InsertDBArg ExtraKey = "InsertDBArg"

	CacheKey    ExtraKey = "CacheKey"
	CacheSetArg ExtraKey = "CacheSetArg"

	QueueName ExtraKey = "QueueName"
)

type Logger

type Logger interface {
	Init(appName string)
	Debug(category Category, subCategory SubCategory, message string, extra map[ExtraKey]interface{})
	DebugF(template string, args ...interface{})
	Info(category Category, subCategory SubCategory, message string, extra map[ExtraKey]interface{})
	InfoF(template string, args ...interface{})
	Warn(category Category, subCategory SubCategory, message string, extra map[ExtraKey]interface{})
	WarnF(template string, args ...interface{})
	Error(category Category, subCategory SubCategory, message string, extra map[ExtraKey]interface{})
	ErrorF(template string, args ...interface{})
	Fatal(category Category, subCategory SubCategory, message string, extra map[ExtraKey]interface{})
	FatalF(template string, args ...interface{})
}

func NewLogger

func NewLogger(appName string, config config.Log) Logger

type MockLogger

type MockLogger struct {
	mock.Mock
}

func (*MockLogger) Debug

func (r *MockLogger) Debug(category Category, subCategory SubCategory, message string, extra map[ExtraKey]interface{})

func (*MockLogger) DebugF

func (r *MockLogger) DebugF(template string, args ...interface{})

func (*MockLogger) Error

func (r *MockLogger) Error(category Category, subCategory SubCategory, message string, extra map[ExtraKey]interface{})

func (*MockLogger) ErrorF

func (r *MockLogger) ErrorF(template string, args ...interface{})

func (*MockLogger) Fatal

func (r *MockLogger) Fatal(category Category, subCategory SubCategory, message string, extra map[ExtraKey]interface{})

func (*MockLogger) FatalF

func (r *MockLogger) FatalF(template string, args ...interface{})

func (*MockLogger) Info

func (r *MockLogger) Info(category Category, subCategory SubCategory, message string, extra map[ExtraKey]interface{})

func (*MockLogger) InfoF

func (r *MockLogger) InfoF(template string, args ...interface{})

func (*MockLogger) Init

func (r *MockLogger) Init(appName string)

func (*MockLogger) Warn

func (r *MockLogger) Warn(category Category, subCategory SubCategory, message string, extra map[ExtraKey]interface{})

func (*MockLogger) WarnF

func (r *MockLogger) WarnF(template string, args ...interface{})

type SubCategory

type SubCategory string
const (
	InternalInfo SubCategory = "InternalInfo"

	Startup         SubCategory = "Startup"
	Shutdown        SubCategory = "Shutdown"
	ExternalService SubCategory = "ExternalService"

	API                 SubCategory = "API"
	DefaultRoleNotFound SubCategory = "DefaultRoleNotFound"

	DatabaseConnectionError  SubCategory = "DatabaseConnectionError"
	DatabaseQueryError       SubCategory = "DatabaseQueryError"
	DatabaseSelect           SubCategory = "DatabaseSelect"
	DatabaseInsert           SubCategory = "DatabaseInsert"
	DatabaseUpdate           SubCategory = "DatabaseUpdate"
	DatabaseDelete           SubCategory = "DatabaseDelete"
	DatabaseBeginTransaction SubCategory = "DatabaseBeginTransaction"
	DatabaseCommit           SubCategory = "DatabaseCommit"
	DatabaseRollback         SubCategory = "DatabaseRollback"
	DatabasePrepare          SubCategory = "DatabasePrepare"
	MigrationUp              SubCategory = "MigrationUp"
	MigrationDown            SubCategory = "MigrationDown"

	Redis         SubCategory = "Redis"
	RedisRemember SubCategory = "RedisRemember"
	RedisSet      SubCategory = "RedisSet"
	RedisGet      SubCategory = "RedisGet"
	RedisDel      SubCategory = "RedisDel"
	RedisPing     SubCategory = "RedisPing"

	ValidationFailed SubCategory = "ValidationFailed"

	RequestError SubCategory = "RequestError"

	RemoveFile SubCategory = "RemoveFile"

	JWTGenerate SubCategory = "JWTGenerate"

	CheckAccess SubCategory = "CheckAccess"

	NotificationSend SubCategory = "NotificationSend"

	SlackSendMessage SubCategory = "SlackSendMessage"

	TwilioWebhook     SubCategory = "TwilioWebhook"
	TwilioSendSMS     SubCategory = "TwilioSendSMS"
	TwilioCheck       SubCategory = "TwilioCheck"
	TwilioRetrySMS    SubCategory = "TwilioRetrySMS"
	TwilioUpdateSMS   SubCategory = "TwilioUpdateSMS"
	VonageWebhook     SubCategory = "VonageWebhook"
	VonageSendSMS     SubCategory = "VonageSendSMS"
	VonageCheck       SubCategory = "VonageCheck"
	VonageRetrySMS    SubCategory = "VonageRetrySMS"
	VonageUpdateSMS   SubCategory = "VonageUpdateSMS"
	SendGridSendEmail SubCategory = "SendGridSendEmail"
	SendEmail         SubCategory = "SendEmail"

	GoogleLogin   SubCategory = "GoogleLogin"
	FacebookLogin SubCategory = "FacebookLogin"
	AppleLogin    SubCategory = "AppleLogin"

	DataConversion SubCategory = "DataConversion"

	RabbitMQ                 SubCategory = "RabbitMQ"
	RabbitMQProduce          SubCategory = "RabbitMQProduce"
	RabbitMQPublish          SubCategory = "RabbitMQPublish"
	RabbitMQConsume          SubCategory = "RabbitMQConsume"
	RabbitMQRegisterConsumer SubCategory = "RabbitMQRegisterConsumer"

	MinioCreateBucket SubCategory = "MinioCreateBucket"
	MinioUpload       SubCategory = "MinioUpload"

	GetTOTP     SubCategory = "GetTOTP"
	EnrollTOTP  SubCategory = "EnrollTOTP"
	EnableTOTP  SubCategory = "EnableTOTP"
	VerifyTOTP  SubCategory = "VerifyTOTP"
	DisableTOTP SubCategory = "DisableTOTP"
)

type ZapLogger

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

func (*ZapLogger) Debug

func (r *ZapLogger) Debug(cat Category, sub SubCategory, msg string, extra map[ExtraKey]interface{})

func (*ZapLogger) DebugF

func (r *ZapLogger) DebugF(template string, args ...interface{})

func (*ZapLogger) Error

func (r *ZapLogger) Error(cat Category, sub SubCategory, msg string, extra map[ExtraKey]interface{})

func (*ZapLogger) ErrorF

func (r *ZapLogger) ErrorF(template string, args ...interface{})

func (*ZapLogger) Fatal

func (r *ZapLogger) Fatal(cat Category, sub SubCategory, msg string, extra map[ExtraKey]interface{})

func (*ZapLogger) FatalF

func (r *ZapLogger) FatalF(template string, args ...interface{})

func (*ZapLogger) GetLogLevel

func (r *ZapLogger) GetLogLevel() zapcore.Level

func (*ZapLogger) Info

func (r *ZapLogger) Info(cat Category, sub SubCategory, msg string, extra map[ExtraKey]interface{})

func (*ZapLogger) InfoF

func (r *ZapLogger) InfoF(template string, args ...interface{})

func (*ZapLogger) Init

func (r *ZapLogger) Init(appName string)

func (*ZapLogger) Warn

func (r *ZapLogger) Warn(cat Category, sub SubCategory, msg string, extra map[ExtraKey]interface{})

func (*ZapLogger) WarnF

func (r *ZapLogger) WarnF(template string, args ...interface{})

Jump to

Keyboard shortcuts

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