Skip to content

Commit 5387abb

Browse files
authored
Merge pull request #29 from DexterHaslem/logging-levels
Add basic logging levels
2 parents 9899793 + 5de712f commit 5387abb

File tree

13 files changed

+822
-767
lines changed

13 files changed

+822
-767
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ import "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox"
4343
import "github.com/dropbox/dropbox-sdk-go-unofficial/dropbox/users"
4444

4545
func main() {
46-
config := dropbox.Config{Token: token, Verbose: true} // second arg enables verbose logging in the SDK
46+
config := dropbox.Config{
47+
Token: token,
48+
LogLevel: dropbox.LogInfo // if needed, set the desired logging level. Default is off
49+
}
4750
dbx := users.New(config)
4851
// start making API calls
4952
}

dropbox/auth/client.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type TokenFromOauth1APIError struct {
4949
func (dbx *apiImpl) TokenFromOauth1(arg *TokenFromOAuth1Arg) (res *TokenFromOAuth1Result, err error) {
5050
cli := dbx.Client
5151

52-
dbx.Config.TryLog("arg: %v", arg)
52+
dbx.Config.LogDebug("arg: %v", arg)
5353
b, err := json.Marshal(arg)
5454
if err != nil {
5555
return
@@ -66,21 +66,21 @@ func (dbx *apiImpl) TokenFromOauth1(arg *TokenFromOAuth1Arg) (res *TokenFromOAut
6666
if err != nil {
6767
return
6868
}
69-
dbx.Config.TryLog("req: %v", req)
69+
dbx.Config.LogInfo("req: %v", req)
7070

7171
resp, err := cli.Do(req)
7272
if err != nil {
7373
return
7474
}
7575

76-
dbx.Config.TryLog("resp: %v", resp)
76+
dbx.Config.LogInfo("resp: %v", resp)
7777
defer resp.Body.Close()
7878
body, err := ioutil.ReadAll(resp.Body)
7979
if err != nil {
8080
return
8181
}
8282

83-
dbx.Config.TryLog("body: %v", body)
83+
dbx.Config.LogDebug("body: %v", body)
8484
if resp.StatusCode == http.StatusOK {
8585
err = json.Unmarshal(body, &res)
8686
if err != nil {
@@ -130,21 +130,21 @@ func (dbx *apiImpl) TokenRevoke() (err error) {
130130
if err != nil {
131131
return
132132
}
133-
dbx.Config.TryLog("req: %v", req)
133+
dbx.Config.LogInfo("req: %v", req)
134134

135135
resp, err := cli.Do(req)
136136
if err != nil {
137137
return
138138
}
139139

140-
dbx.Config.TryLog("resp: %v", resp)
140+
dbx.Config.LogInfo("resp: %v", resp)
141141
defer resp.Body.Close()
142142
body, err := ioutil.ReadAll(resp.Body)
143143
if err != nil {
144144
return
145145
}
146146

147-
dbx.Config.TryLog("body: %v", body)
147+
dbx.Config.LogDebug("body: %v", body)
148148
if resp.StatusCode == http.StatusOK {
149149
return
150150
}

0 commit comments

Comments
 (0)