-
Notifications
You must be signed in to change notification settings - Fork 1
/
wrap.go
45 lines (42 loc) · 973 Bytes
/
wrap.go
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package log
// UnwrapLogger unwraps a wrapped Logger inside of another Logger. For example
// by NewLoggerFacade.
func UnwrapLogger(in CoreLogger) Logger {
if u, ok := in.(interface {
Unwrap() Logger
}); ok {
return u.Unwrap()
} else if u, ok := in.(interface {
Unwrap() CoreLogger
}); ok {
if c := u.Unwrap(); c != nil {
return NewLogger(c)
}
}
return nil
}
// UnwrapCoreLogger unwraps a wrapped CoreLogger inside of another CoreLogger.
// For example by NewLoggerFacade.
func UnwrapCoreLogger(in CoreLogger) CoreLogger {
if u, ok := in.(interface {
Unwrap() Logger
}); ok {
return u.Unwrap()
}
if u, ok := in.(interface {
Unwrap() CoreLogger
}); ok {
return u.Unwrap()
}
return nil
}
// UnwrapProvider unwraps a wrapped Provider inside of another Provider. For
// example by NewProviderFacade.
func UnwrapProvider(in Provider) Provider {
if u, ok := in.(interface {
Unwrap() Provider
}); ok {
return u.Unwrap()
}
return nil
}