-
-
Notifications
You must be signed in to change notification settings - Fork 195
/
logger.go
29 lines (25 loc) · 740 Bytes
/
logger.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
package gocrawl
import (
"fmt"
)
// LogFlags is a set of flags that control the logging of the Crawler.
type LogFlags uint
// Log levels for the library's logger
const (
LogError LogFlags = 1 << iota
LogInfo
LogEnqueued
LogIgnored
LogTrace
LogNone LogFlags = 0
LogAll LogFlags = LogError | LogInfo | LogEnqueued | LogIgnored | LogTrace
)
func getLogFunc(ext Extender, verbosity LogFlags, workerIndex int) func(LogFlags, string, ...interface{}) {
return func(minLevel LogFlags, format string, vals ...interface{}) {
if workerIndex > 0 {
ext.Log(verbosity, minLevel, fmt.Sprintf(fmt.Sprintf("worker %d - %s", workerIndex, format), vals...))
} else {
ext.Log(verbosity, minLevel, fmt.Sprintf(format, vals...))
}
}
}