AUTH-2810 added warn for backwards compatibility sake
This commit is contained in:
parent
acb7d604fd
commit
55acf7283c
|
@ -6,6 +6,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/cloudflare/cloudflared/carrier"
|
"github.com/cloudflare/cloudflared/carrier"
|
||||||
|
"github.com/cloudflare/cloudflared/cmd/cloudflared/cliutil"
|
||||||
"github.com/cloudflare/cloudflared/cmd/cloudflared/config"
|
"github.com/cloudflare/cloudflared/cmd/cloudflared/config"
|
||||||
"github.com/cloudflare/cloudflared/h2mux"
|
"github.com/cloudflare/cloudflared/h2mux"
|
||||||
"github.com/cloudflare/cloudflared/logger"
|
"github.com/cloudflare/cloudflared/logger"
|
||||||
|
@ -67,7 +68,7 @@ func ssh(c *cli.Context) error {
|
||||||
|
|
||||||
logger, err := logger.New(logger.DefaultFile(logDirectory), logger.LogLevelString(logLevel))
|
logger, err := logger.New(logger.DefaultFile(logDirectory), logger.LogLevelString(logLevel))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "error setting up logger")
|
return cliutil.PrintLoggerSetupError("error setting up logger", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the hostname from the cmdline and error out if its not provided
|
// get the hostname from the cmdline and error out if its not provided
|
||||||
|
|
|
@ -2,8 +2,10 @@ package cliutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/cloudflare/cloudflared/logger"
|
"github.com/cloudflare/cloudflared/logger"
|
||||||
|
"github.com/pkg/errors"
|
||||||
"gopkg.in/urfave/cli.v2"
|
"gopkg.in/urfave/cli.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -39,3 +41,15 @@ func ErrorHandler(actionFunc cli.ActionFunc) cli.ActionFunc {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PrintLoggerSetupError returns an error to stdout to notify when a logger can't start
|
||||||
|
func PrintLoggerSetupError(msg string, err error) error {
|
||||||
|
l, le := logger.New()
|
||||||
|
if le != nil {
|
||||||
|
log.Printf("%s: %s", msg, err)
|
||||||
|
} else {
|
||||||
|
l.Errorf("%s: %s", msg, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors.Wrap(err, msg)
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cloudflare/cloudflared/cmd/cloudflared/access"
|
"github.com/cloudflare/cloudflared/cmd/cloudflared/access"
|
||||||
|
"github.com/cloudflare/cloudflared/cmd/cloudflared/cliutil"
|
||||||
"github.com/cloudflare/cloudflared/cmd/cloudflared/config"
|
"github.com/cloudflare/cloudflared/cmd/cloudflared/config"
|
||||||
"github.com/cloudflare/cloudflared/cmd/cloudflared/tunnel"
|
"github.com/cloudflare/cloudflared/cmd/cloudflared/tunnel"
|
||||||
"github.com/cloudflare/cloudflared/cmd/cloudflared/updater"
|
"github.com/cloudflare/cloudflared/cmd/cloudflared/updater"
|
||||||
|
@ -165,16 +166,15 @@ func handleError(err error) {
|
||||||
|
|
||||||
// cloudflared was started without any flags
|
// cloudflared was started without any flags
|
||||||
func handleServiceMode(shutdownC chan struct{}) error {
|
func handleServiceMode(shutdownC chan struct{}) error {
|
||||||
|
defer log.SharedWriteManager.Shutdown()
|
||||||
logDirectory, logLevel := config.FindLogSettings()
|
logDirectory, logLevel := config.FindLogSettings()
|
||||||
|
|
||||||
logger, err := log.New(log.DefaultFile(logDirectory), log.LogLevelString(logLevel))
|
logger, err := log.New(log.DefaultFile(logDirectory), log.LogLevelString(logLevel))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "error setting up logger")
|
return cliutil.PrintLoggerSetupError("error setting up logger", err)
|
||||||
}
|
}
|
||||||
logger.Infof("logging to directory: %s", logDirectory)
|
logger.Infof("logging to directory: %s", logDirectory)
|
||||||
|
|
||||||
defer log.SharedWriteManager.Shutdown()
|
|
||||||
|
|
||||||
// start the main run loop that reads from the config file
|
// start the main run loop that reads from the config file
|
||||||
f, err := watcher.NewFile()
|
f, err := watcher.NewFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -235,7 +235,7 @@ func createLogger(c *cli.Context, isTransport bool) (logger.Service, error) {
|
||||||
func StartServer(c *cli.Context, version string, shutdownC, graceShutdownC chan struct{}) error {
|
func StartServer(c *cli.Context, version string, shutdownC, graceShutdownC chan struct{}) error {
|
||||||
logger, err := createLogger(c, false)
|
logger, err := createLogger(c, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "error setting up logger")
|
return cliutil.PrintLoggerSetupError("error setting up logger", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = raven.SetDSN(sentryDSN)
|
_ = raven.SetDSN(sentryDSN)
|
||||||
|
@ -478,7 +478,7 @@ func StartServer(c *cli.Context, version string, shutdownC, graceShutdownC chan
|
||||||
func Before(c *cli.Context) error {
|
func Before(c *cli.Context) error {
|
||||||
logger, err := createLogger(c, false)
|
logger, err := createLogger(c, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "error setting up logger")
|
return cliutil.PrintLoggerSetupError("error setting up logger", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.String("config") == "" {
|
if c.String("config") == "" {
|
||||||
|
|
|
@ -141,7 +141,7 @@ func ParseLevelString(lvl string) ([]Level, error) {
|
||||||
return []Level{FatalLevel}, nil
|
return []Level{FatalLevel}, nil
|
||||||
case "error":
|
case "error":
|
||||||
return []Level{FatalLevel, ErrorLevel}, nil
|
return []Level{FatalLevel, ErrorLevel}, nil
|
||||||
case "info":
|
case "info", "warn":
|
||||||
return []Level{FatalLevel, ErrorLevel, InfoLevel}, nil
|
return []Level{FatalLevel, ErrorLevel, InfoLevel}, nil
|
||||||
case "debug":
|
case "debug":
|
||||||
return []Level{FatalLevel, ErrorLevel, InfoLevel, DebugLevel}, nil
|
return []Level{FatalLevel, ErrorLevel, InfoLevel, DebugLevel}, nil
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/cloudflare/cloudflared/cmd/cloudflared/cliutil"
|
||||||
"github.com/cloudflare/cloudflared/cmd/cloudflared/config"
|
"github.com/cloudflare/cloudflared/cmd/cloudflared/config"
|
||||||
"github.com/cloudflare/cloudflared/logger"
|
"github.com/cloudflare/cloudflared/logger"
|
||||||
"github.com/cloudflare/cloudflared/metrics"
|
"github.com/cloudflare/cloudflared/metrics"
|
||||||
|
@ -31,7 +32,7 @@ func Run(c *cli.Context) error {
|
||||||
logDirectory, logLevel := config.FindLogSettings()
|
logDirectory, logLevel := config.FindLogSettings()
|
||||||
logger, err := logger.New(logger.DefaultFile(logDirectory), logger.LogLevelString(logLevel))
|
logger, err := logger.New(logger.DefaultFile(logDirectory), logger.LogLevelString(logLevel))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "error setting up logger")
|
return cliutil.PrintLoggerSetupError("error setting up logger", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
metricsListener, err := net.Listen("tcp", c.String("metrics"))
|
metricsListener, err := net.Listen("tcp", c.String("metrics"))
|
||||||
|
|
Loading…
Reference in New Issue