-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
50 lines (41 loc) · 1.36 KB
/
utils.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
46
47
48
49
50
package inbox
import (
"github.com/benpate/hannibal/vocab"
"github.com/rs/zerolog"
)
// IsActivityPubContentType returns true if the specified content-type is an ActivityPub content-type
func IsActivityPubContentType(contentType string) bool {
if contentType == vocab.ContentTypeActivityPub {
return true
}
if contentType == vocab.ContentTypeJSONLD {
return true
}
return false
}
// canLog is a silly zerolog helper that returns TRUE
// if the provided log level would be allowed
// (based on the global log level).
// This makes it easier to execute expensive code conditionally,
// for instance: marshalling a JSON object for logging.
func canLog(level zerolog.Level) bool {
return zerolog.GlobalLevel() <= level
}
// canTrace returns TRUE if zerolog is configured to allow Trace logs
// This function is here for completeness. It may or may not be used
// nolint: unused
func canTrace() bool {
return canLog(zerolog.TraceLevel)
}
// canDebug returns TRUE if zerolog is configured to allow Debug logs
// This function is here for completeness. It may or may not be used
// nolint: unused
func canDebug() bool {
return canLog(zerolog.DebugLevel)
}
// canInfo returns TRUE if zerolog is configured to allow Info logs
// This function is here for completeness. It may or may not be used
// nolint: unused
func canInfo() bool {
return canLog(zerolog.InfoLevel)
}