A Windows application compiles fine and works if there are no problems. But for example, turn off the SQL server, and the application starts to pour into the console:

goroutine 5 [chan receive]:

database / sql. (* DB) .connectionOpener (0xc0820500b0) C: /Go/src/database/sql/sql.go: 727 + 0x4c

created by database / sql.Open C: /Go/src/database/sql/sql.go: 493 + 0x346

Although I use logrus and write all the errors to the log file, but for some reason this is exactly where nothing gets. Perhaps somehow it is to intercept and suppress the output to the screen?

  • You write in logrus. And where does the functionality of the package for working with SQL server write? Generally, what kind of package? We need to see what kind of logger it uses and configure it. - mals
  • I use github.com/lib/pq Ok, ATP, I'll drink. - Darkman
  • @MaLS figured it out, the problem was a bit different, it just gave to another :)) A question for your answer. And how can I bind the current logger to other used packages, for example, here I use github.com/labstack/echo , there is echo.SetLogger (), but how can I shove a logger into it with a parameter? Logrus I use via: import log "github.com/Sirupsen/logrus" - Darkman
  • In the GO did not encounter such a need. In .NET (practice has shown) when you start to assemble a lot of components that use different loggers you have to use adapters. These adapters intercept the process of recording one logger and write to another. - mals
  • @Darkman in logrus you can get a pointer to the standard logger. logger := logrus.StandardLogger() , and then later logger pass to echo.SetLogger() - Pavel Kazhevets

0