-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.go
47 lines (38 loc) · 821 Bytes
/
log.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
package main
import (
"flag"
"fmt"
"log"
)
type logger struct{}
func (writer logger) Write(bytes []byte) (int, error) {
return fmt.Print(string(bytes))
}
func initLogger() {
log.SetFlags(0)
log.SetOutput(new(logger))
}
func printVersion() {
log.Printf("Logpasta CLI %s", version)
}
func printUsage() {
var flags string
flag.VisitAll(func(f *flag.Flag) {
flags += f.Name
})
log.Printf(
"Usage of logpasta:\n logpasta [-%s] [text ...]\n [command] | logpasta [-%s]\n logpasta [-%s] < [file]\n\n",
flags, flags, flags,
)
log.Println("Options:")
flag.PrintDefaults()
}
func printDebugInfo(conf *Config) {
log.Printf("Running with config:\n - BaseURL: %s\n - Silent: %v\n - Debug: %v\n - Timeout: %d\n - Copy: %v",
conf.BaseURL,
conf.Silent,
conf.Debug,
conf.Timeout,
conf.Copy,
)
}