add FN_LOG_DEST for logs, fixup init (#663)

* add FN_LOG_DEST for logs, fixup init

* FN_LOG_DEST can point to a remote logging place (papertrail, whatever)
* FN_LOG_PREFIX can add a prefix onto each log line sent to FN_LOG_DEST

default remains stderr with no prefix. users need this to send to various
logging backends, though it could be done operationally, this is somewhat
simpler.

we were doing some configuration stuff inside of init() for some of the global
things. even though they're global, it's nice to keep them all in the normal
server init path.

we have had strange issues with the tracing setup, I tested the last repro of
this repeatedly and didn't have any luck reproducing it, though maybe it comes
back.

* add docs
This commit is contained in:
Reed Allman
2018-01-09 14:27:50 -08:00
committed by GitHub
parent 5fe2fa1aee
commit 24aa911609
4 changed files with 79 additions and 57 deletions

View File

@@ -4,6 +4,7 @@ import (
"net/url"
"os"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
)
@@ -18,6 +19,12 @@ func SetLogLevel(ll string) {
logLevel = logrus.InfoLevel
}
logrus.SetLevel(logLevel)
// this effectively just adds more gin log goodies
gin.SetMode(gin.ReleaseMode)
if logLevel == logrus.DebugLevel {
gin.SetMode(gin.DebugMode)
}
}
func SetLogDest(to, prefix string) {