title: Passing a global reference to beego controllers
body: <p>I'm trying to pass a logger reference initialised inside main.go to Controller layer via the router like bellow</p>
  
  <p>main.go</p>
  
  <pre><code>logger, _ := zap.NewProduction()
  defer logger.Sync() // flushes buffer, if any
  sugar := logger.Sugar()
  routers.Init(sugar)
  </code></pre>
  
  <p>routers.go</p>
  
  <pre><code>func Init(l *zap.SugaredLogger) {
     nsMgt := beego.NewNamespace("/api",
      beego.NSNamespace("/account",
          beego.NSInclude(
              &amp;controllers.AccountController{
                  Logger: l,
              },
          ),
      ),
     )
  )
  </code></pre>
  
  <p>controller.go</p>
  
  <pre><code>type AccountController struct {
     beego.Controller
     Logger *zap.SugaredLogger
  }
  
  // @Title Get account details.
  // @Summary Get account details
  // @Param   filterKey query string  true "possible values 'id' or 'username'"
  // @Param   filterValue query string  true "value of the filter key"
  // @Success 200 {object} models.User
  // @router / [get]
  func (o *AccountController) Get() {
       o.Logger.Info("this is cool")
  }
  </code></pre>
  
  <p>It throws a null pointer error at the controller function. Is there a way to pass a global logger variable to controller layer?. It's important to initialise the logger at the main function 'cause it requires a defered close.</p>