-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMain.go
60 lines (48 loc) · 1.15 KB
/
Main.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
51
52
53
54
55
56
57
58
59
60
package main
import (
"flag"
"fmt"
"os"
"github.com/BioSchemas/bioschemas-goweb/bioparser"
"github.com/rifflock/lfshook"
log "github.com/sirupsen/logrus"
)
var (
version string
buildDate string
)
func logInit(d bool) {
logfile := "goweb.log"
fmt.Println("Loging to " + logfile)
log.SetOutput(os.Stdout)
if d {
log.SetLevel(log.DebugLevel)
} else {
log.SetLevel(log.InfoLevel)
}
log.SetFormatter(&log.TextFormatter{})
pathMap := lfshook.PathMap{
log.DebugLevel: logfile,
log.InfoLevel: logfile,
log.ErrorLevel: logfile,
log.WarnLevel: logfile,
log.PanicLevel: logfile,
}
log.AddHook(lfshook.NewHook(
pathMap,
&log.JSONFormatter{},
))
}
func main() {
d := flag.Bool("d", false, "Sets up the log level to debug")
v := flag.Bool("v", false, "Returns the binary version and built date info")
f := flag.String("f", "", "File path to Bioschemas CSV file to parse")
u := flag.String("u", "", "Url Path to Bioschemas CSV info to parse")
flag.Parse()
logInit(*d)
log.Info("--------------Init program--------------")
log.Info(fmt.Sprintf("Version: %s Build Date: %s", version, buildDate))
if !*v {
bioparser.Start(*u, *f)
}
}