Skip to content

Commit

Permalink
chore: add more info in log (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
CorrectRoadH authored Jul 22, 2024
1 parent f235286 commit c2ad9f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions repository/repository_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}

Expand Down
3 changes: 3 additions & 0 deletions service/socketio_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))

Expand All @@ -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))
})

Expand Down

0 comments on commit c2ad9f9

Please sign in to comment.