mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
simplified logging.
This commit is contained in:
parent
5130d94bbc
commit
fd35254487
@ -45,63 +45,45 @@ type WebSocketManagerCtx struct {
|
||||
|
||||
func (manager *WebSocketManagerCtx) Start() {
|
||||
manager.sessions.OnCreated(func(session types.Session) {
|
||||
logger := manager.logger.With().Str("session_id", session.ID()).Logger()
|
||||
|
||||
if err := manager.handler.SessionCreated(session); err != nil {
|
||||
logger.Warn().Err(err).Msg("session created with an error")
|
||||
} else {
|
||||
logger.Debug().Msg("session created")
|
||||
}
|
||||
err := manager.handler.SessionCreated(session)
|
||||
manager.logger.Err(err).
|
||||
Str("session_id", session.ID()).
|
||||
Msg("session created")
|
||||
})
|
||||
|
||||
manager.sessions.OnDeleted(func(session types.Session) {
|
||||
logger := manager.logger.With().Str("session_id", session.ID()).Logger()
|
||||
|
||||
if err := manager.handler.SessionDeleted(session); err != nil {
|
||||
logger.Warn().Err(err).Msg("session deleted with an error")
|
||||
} else {
|
||||
logger.Debug().Msg("session deleted")
|
||||
}
|
||||
err := manager.handler.SessionDeleted(session)
|
||||
manager.logger.Err(err).
|
||||
Str("session_id", session.ID()).
|
||||
Msg("session deleted")
|
||||
})
|
||||
|
||||
manager.sessions.OnConnected(func(session types.Session) {
|
||||
logger := manager.logger.With().Str("session_id", session.ID()).Logger()
|
||||
|
||||
if err := manager.handler.SessionConnected(session); err != nil {
|
||||
logger.Warn().Err(err).Msg("session connected with an error")
|
||||
} else {
|
||||
logger.Debug().Msg("session connected")
|
||||
}
|
||||
err := manager.handler.SessionConnected(session)
|
||||
manager.logger.Err(err).
|
||||
Str("session_id", session.ID()).
|
||||
Msg("session connected")
|
||||
})
|
||||
|
||||
manager.sessions.OnDisconnected(func(session types.Session) {
|
||||
logger := manager.logger.With().Str("session_id", session.ID()).Logger()
|
||||
|
||||
if err := manager.handler.SessionDisconnected(session); err != nil {
|
||||
logger.Warn().Err(err).Msg("session disconnected with an error")
|
||||
} else {
|
||||
logger.Debug().Msg("session disconnected")
|
||||
}
|
||||
err := manager.handler.SessionDisconnected(session)
|
||||
manager.logger.Err(err).
|
||||
Str("session_id", session.ID()).
|
||||
Msg("session disconnected")
|
||||
})
|
||||
|
||||
manager.sessions.OnProfileChanged(func(session types.Session) {
|
||||
logger := manager.logger.With().Str("session_id", session.ID()).Logger()
|
||||
|
||||
if err := manager.handler.SessionProfileChanged(session); err != nil {
|
||||
logger.Warn().Err(err).Msg("session profile changed with an error")
|
||||
} else {
|
||||
logger.Debug().Interface("profile", session.Profile()).Msg("session profile changed")
|
||||
}
|
||||
err := manager.handler.SessionProfileChanged(session)
|
||||
manager.logger.Err(err).
|
||||
Str("session_id", session.ID()).
|
||||
Msg("session profile changed")
|
||||
})
|
||||
|
||||
manager.sessions.OnStateChanged(func(session types.Session) {
|
||||
logger := manager.logger.With().Str("session_id", session.ID()).Logger()
|
||||
|
||||
if err := manager.handler.SessionStateChanged(session); err != nil {
|
||||
logger.Warn().Err(err).Msg("session state changed with an error")
|
||||
} else {
|
||||
logger.Debug().Interface("state", session.State()).Msg("session state changed")
|
||||
}
|
||||
err := manager.handler.SessionStateChanged(session)
|
||||
manager.logger.Err(err).
|
||||
Str("session_id", session.ID()).
|
||||
Msg("session state changed")
|
||||
})
|
||||
|
||||
manager.sessions.OnHostChanged(func(session types.Session) {
|
||||
|
51
neko.go
51
neko.go
@ -195,47 +195,28 @@ func (neko *Neko) Start() {
|
||||
}
|
||||
|
||||
func (neko *Neko) Shutdown() {
|
||||
if err := neko.memberManager.Disconnect(); err != nil {
|
||||
neko.logger.Err(err).Msg("member manager disconnect with an error")
|
||||
} else {
|
||||
neko.logger.Debug().Msg("member manager disconnect")
|
||||
}
|
||||
var err error
|
||||
|
||||
if err := neko.desktopManager.Shutdown(); err != nil {
|
||||
neko.logger.Err(err).Msg("desktop manager shutdown with an error")
|
||||
} else {
|
||||
neko.logger.Debug().Msg("desktop manager shutdown")
|
||||
}
|
||||
err = neko.memberManager.Disconnect()
|
||||
neko.logger.Err(err).Msg("member manager disconnect")
|
||||
|
||||
if err := neko.captureManager.Shutdown(); err != nil {
|
||||
neko.logger.Err(err).Msg("capture manager shutdown with an error")
|
||||
} else {
|
||||
neko.logger.Debug().Msg("capture manager shutdown")
|
||||
}
|
||||
err = neko.desktopManager.Shutdown()
|
||||
neko.logger.Err(err).Msg("desktop manager shutdown")
|
||||
|
||||
if err := neko.webRTCManager.Shutdown(); err != nil {
|
||||
neko.logger.Err(err).Msg("webrtc manager shutdown with an error")
|
||||
} else {
|
||||
neko.logger.Debug().Msg("webrtc manager shutdown")
|
||||
}
|
||||
err = neko.captureManager.Shutdown()
|
||||
neko.logger.Err(err).Msg("capture manager shutdown")
|
||||
|
||||
if err := neko.webSocketManager.Shutdown(); err != nil {
|
||||
neko.logger.Err(err).Msg("websocket manager shutdown with an error")
|
||||
} else {
|
||||
neko.logger.Debug().Msg("websocket manager shutdown")
|
||||
}
|
||||
err = neko.webRTCManager.Shutdown()
|
||||
neko.logger.Err(err).Msg("webrtc manager shutdown")
|
||||
|
||||
if err := modules.Shutdown(); err != nil {
|
||||
neko.logger.Err(err).Msg("modules shutdown with an error")
|
||||
} else {
|
||||
neko.logger.Debug().Msg("modules shutdown")
|
||||
}
|
||||
err = neko.webSocketManager.Shutdown()
|
||||
neko.logger.Err(err).Msg("websocket manager shutdown")
|
||||
|
||||
if err := neko.httpManager.Shutdown(); err != nil {
|
||||
neko.logger.Err(err).Msg("http manager shutdown with an error")
|
||||
} else {
|
||||
neko.logger.Debug().Msg("http manager shutdown")
|
||||
}
|
||||
err = modules.Shutdown()
|
||||
neko.logger.Err(err).Msg("modules shutdown")
|
||||
|
||||
err = neko.httpManager.Shutdown()
|
||||
neko.logger.Err(err).Msg("http manager shutdown")
|
||||
}
|
||||
|
||||
func (neko *Neko) ServeCommand(cmd *cobra.Command, args []string) {
|
||||
|
Loading…
Reference in New Issue
Block a user