forked from rclone/go-proton-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.go
More file actions
29 lines (24 loc) · 713 Bytes
/
Copy pathlogger.go
File metadata and controls
29 lines (24 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package proton
import (
"sync/atomic"
"github.com/go-resty/resty/v2"
)
// pkgLogger is used by package-level code paths that don't have access
// to a Manager (currently Keys.Unlock and the retry-after middleware).
// It is updated whenever a Manager is built with the WithLogger option;
// the most recently configured logger wins. When nil, the call sites
// fall back to logrus so the library's historical behaviour is
// preserved for callers that don't supply a logger.
var pkgLogger atomic.Pointer[resty.Logger]
func setPkgLogger(l resty.Logger) {
if l == nil {
return
}
pkgLogger.Store(&l)
}
func getPkgLogger() resty.Logger {
if l := pkgLogger.Load(); l != nil {
return *l
}
return nil
}