added rabbitmq

alpha v1.0.44
alex 2023-02-18 08:41:57 +01:00
parent 72d39eb216
commit 7f7d29ca1e
1 changed files with 21 additions and 9 deletions

View File

@ -11,14 +11,26 @@ import (
var (
logsClient *Client
gserviceName string
gserviceType string
gserviceName uint8
gserviceType uint8
grabbitMqLoggingEnabled bool
)
const RabbitMqQueueLogs = "cnj.logs"
const (
RabbitMqQueueLogs = "cnj.logs"
func InitLogger(debug bool, colorizedOutput bool, rabbitMqLogging bool, rabbitMqConnAddr string, serviceName string, serviceType string) {
ServiceNameAPI = 0
ServiceNameMailer = 1
ServiceNameStorageServer = 2
ServiceNameSSEServer = 3
ServiceNameWSServer = 4
ServiceTypeAlpha = 0
ServiceTypeBeta = 1
ServiceTypeStable = 2
)
func InitLogger(debug bool, colorizedOutput bool, rabbitMqLogging bool, rabbitMqConnAddr string, serviceName uint8, serviceType uint8) {
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
if debug {
@ -102,8 +114,8 @@ func LogFatalf(format string, v ...interface{}) {
type RabbitMqLogMessage struct {
MessageType uint8
ServiceName string
ServiceType string
ServiceName uint8
ServiceType uint8
Msg string
Timestamp int64
}
@ -114,9 +126,9 @@ func pushLogMessage(messageType uint8, logMsg string) {
}
rabbitMqLogMessage := RabbitMqLogMessage{
MessageType: messageType,
ServiceName: gserviceName,
ServiceType: gserviceType,
MessageType: messageType, // could be debug, info
ServiceName: gserviceName, // could be API
ServiceType: gserviceType, // could be alpha
Msg: logMsg,
Timestamp: time.Now().Unix(),
}