MCPcopy Index your code
hub / github.com/perkeep/perkeep / init

Function init

cmd/pk-put/put.go:68–102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

66}
67
68func init() {
69 // So we can simply use log.Printf and log.Fatalf.
70 // For logging that depends on verbosity (cmdmain.FlagVerbose), use cmdmain.Logf/Printf.
71 log.SetOutput(cmdmain.Stderr)
72 if debug, _ := strconv.ParseBool(os.Getenv("CAMLI_DEBUG")); debug {
73 debugFlagOnce.Do(registerDebugFlags)
74 }
75 cmdmain.ExtraFlagRegistration = client.AddFlags
76 cmdmain.PostFlag = func() {
77 if *flagCacheLog {
78 cachelog = log.New(cmdmain.Stderr, "", log.LstdFlags)
79 } else {
80 // It's only ok to do that because we don't expect any cachelog.Fatal* calls.
81 cachelog = log.New(io.Discard, "", log.LstdFlags)
82 }
83 }
84
85 cmdmain.PreExit = func() {
86 if up := uploader; up != nil {
87 up.Close()
88 stats := up.Stats()
89 cmdmain.Logf("Client stats: %s", stats.String())
90 if up.stats != nil {
91 cmdmain.Logf(" #HTTP reqs: %d", up.stats.Requests())
92 h1, h2 := up.stats.ProtoVersions()
93 cmdmain.Logf(" responses: %d (h1), %d (h2)\n", h1, h2)
94 }
95 }
96
97 // So multiple cmd/pk-put TestFoo funcs run, each with
98 // an fresh (and not previously closed) Uploader:
99 uploader = nil
100 uploaderOnce = sync.Once{}
101 }
102}
103
104func getUploader() *Uploader {
105 uploaderOnce.Do(initUploader)

Callers

nothing calls this directly

Calls 6

LogfFunction · 0.92
RequestsMethod · 0.80
ProtoVersionsMethod · 0.80
CloseMethod · 0.65
StatsMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected