Make logging package usage less tedious
Before, we were exposing a Logger as logging.Log. This works, but results in code calling Logger.Log.Info() which is a little wordy. Instead, the logger is now kept private and we expose Info, Warn and Error as public functions that wrap logger.Info, logger.Warn and logger.Error.
This commit is contained in:
parent
5e4273390f
commit
665717d9e7
2 changed files with 18 additions and 6 deletions
8
main.go
8
main.go
|
|
@ -48,21 +48,21 @@ func startBot() error {
|
|||
|
||||
err := state.DiscordSession.Open()
|
||||
if err != nil {
|
||||
logging.Log.Error("could not open discord session", "type", "error", "error", err)
|
||||
logging.Error("could not open discord session", "type", "error", "error", err)
|
||||
return err
|
||||
}
|
||||
|
||||
logging.Log.Info("shutting down gracefully", "type", "shutdown")
|
||||
logging.Info("shutting down gracefully", "type", "shutdown")
|
||||
|
||||
sigch := make(chan os.Signal, 1)
|
||||
signal.Notify(sigch, os.Interrupt)
|
||||
<-sigch
|
||||
|
||||
logging.Log.Info("shutting down gracefully", "type", "shutdown")
|
||||
logging.Info("shutting down gracefully", "type", "shutdown")
|
||||
|
||||
err = state.DiscordSession.Close()
|
||||
if err != nil {
|
||||
logging.Log.Error("could not close discord session gracefully", "type", "error", "error", err)
|
||||
logging.Error("could not close discord session gracefully", "type", "error", "error", err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue