-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (36 loc) · 866 Bytes
/
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
package main
import (
"fmt"
"os"
pkg "github.com/arael34/qlogger/app"
"github.com/arael34/qlogger/types"
)
func main() {
fmt.Println("starting...")
env, err := pkg.ValidateEnvironment()
if err != nil {
fmt.Printf("Error loading environment: %v\n", err)
os.Exit(1)
}
fmt.Println("\nloaded environment.")
client, err := pkg.ConnectToDatabase(&env.DatabaseUrl, &env.DatabaseName)
if err != nil {
fmt.Printf("Error connecting to database: %v\n", err)
os.Exit(pkg.CloseDatabase(client, 1))
}
fmt.Println("pinged database.")
logger := types.NewQLogger(
&env.AuthHeader,
client.Database(env.DatabaseName).Collection("logs"),
)
app, err := pkg.
NewAppBuilder().
WithClient(client).
WithLogger(logger).
Build()
if err != nil {
fmt.Printf("Error building app: %v\n", err)
os.Exit(pkg.CloseDatabase(client, 1))
}
app.Run()
}