From c2ad9f99a7b1b6ee6ce658b520ed52aff31163aa Mon Sep 17 00:00:00 2001 From: CorrectRoad Date: Mon, 22 Jul 2024 10:12:05 +0800 Subject: [PATCH] chore: add more info in log (#41) --- repository/repository_db.go | 3 +++ service/socketio_service.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/repository/repository_db.go b/repository/repository_db.go index 75dcc93..bc7f3cf 100644 --- a/repository/repository_db.go +++ b/repository/repository_db.go @@ -3,8 +3,10 @@ package repository import ( "time" + "github.com/IceWhaleTech/CasaOS-Common/utils/logger" "github.com/IceWhaleTech/CasaOS-MessageBus/model" "github.com/glebarez/sqlite" + "go.uber.org/zap" "gorm.io/gorm" "gorm.io/gorm/clause" ) @@ -46,6 +48,7 @@ func (r *DatabaseRepository) GetEventType(sourceID string, name string) (*model. var eventType model.EventType if err := r.db.Preload(model.PropertyTypeList).Where(&model.EventType{SourceID: sourceID, Name: name}).First(&eventType).Error; err != nil { + logger.Error("can't find event type", zap.String("sourceID", sourceID), zap.String("EventName", name), zap.Error(err)) return nil, err } diff --git a/service/socketio_service.go b/service/socketio_service.go index e57cc52..72ef2ab 100644 --- a/service/socketio_service.go +++ b/service/socketio_service.go @@ -67,6 +67,7 @@ func buildServer() *socketio.Server { }) server.OnConnect("/", func(s socketio.Conn) error { + // TODO add connector info. we need to know who is connecting s.SetContext("") logger.Info("a socketio connection has started", zap.Any("remote_addr", s.RemoteAddr())) @@ -77,10 +78,12 @@ func buildServer() *socketio.Server { }) server.OnError("/", func(s socketio.Conn, e error) { + // TODO add connector info. we need to know who is disconnecting logger.Error("error in socketio connnection", zap.Any("error", e)) }) server.OnDisconnect("/", func(s socketio.Conn, reason string) { + // TODO add connector info. we need to know who is disconnecting logger.Info("a socketio connection is disconnected", zap.Any("reason", reason)) })