vendor: update github.com/dropbox/dropbox-sdk-go-unofficial to fix #1804
This commit is contained in:
+32
-6
@@ -48,8 +48,8 @@ func Version() (string, string) {
|
||||
type Config struct {
|
||||
// OAuth2 access token
|
||||
Token string
|
||||
// Enable verbose logging in SDK
|
||||
Verbose bool
|
||||
// Logging level for SDK generated logs
|
||||
LogLevel LogLevel
|
||||
// Logging target for verbose SDK logging
|
||||
Logger *log.Logger
|
||||
// Used with APIs that support operations as another user
|
||||
@@ -64,12 +64,28 @@ type Config struct {
|
||||
URLGenerator func(hostType string, style string, namespace string, route string) string
|
||||
}
|
||||
|
||||
// TryLog will, if Verbose is set, log to the config's logger
|
||||
// or the default log (stderr) if Config.Logger is nil.
|
||||
func (c *Config) TryLog(format string, v ...interface{}) {
|
||||
if !c.Verbose {
|
||||
// LogLevel defines a type that can set the desired level of logging the SDK will generate.
|
||||
type LogLevel uint
|
||||
|
||||
const (
|
||||
// LogOff will disable all SDK logging. This is the default log level
|
||||
LogOff LogLevel = iota * (1 << 8)
|
||||
// LogDebug will enable detailed SDK debug logs. It will log requests (including arguments),
|
||||
// response and body contents.
|
||||
LogDebug
|
||||
// LogInfo will log SDK request (not including arguments) and responses.
|
||||
LogInfo
|
||||
)
|
||||
|
||||
func (l LogLevel) ShouldLog(v LogLevel) bool {
|
||||
return l > v || l & v == v
|
||||
}
|
||||
|
||||
func (c *Config) doLog(l LogLevel, format string, v ...interface{}) {
|
||||
if !c.LogLevel.ShouldLog(l) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.Logger != nil {
|
||||
c.Logger.Printf(format, v...)
|
||||
} else {
|
||||
@@ -77,6 +93,16 @@ func (c *Config) TryLog(format string, v ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
// LogDebug emits a debug level SDK log if config's log level is at least LogDebug
|
||||
func (c *Config) LogDebug(format string, v ...interface{}) {
|
||||
c.doLog(LogDebug, format, v...)
|
||||
}
|
||||
|
||||
// LogInfo emits an info level SDK log if config's log level is at least LogInfo
|
||||
func (c *Config) LogInfo(format string, v ...interface{}) {
|
||||
c.doLog(LogInfo, format, v...)
|
||||
}
|
||||
|
||||
// Context is the base client context used to implement per-namespace clients.
|
||||
type Context struct {
|
||||
Config Config
|
||||
|
||||
Reference in New Issue
Block a user