Skip to content

Commit

Permalink
Add a debug flag (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsakalozos authored May 21, 2021
1 parent 256a71a commit 451b3e7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ type Options struct {
StorageDir string
ListenEp string
EnableTls bool
Debug bool
}

func NewOptions() (*Options){
o := Options{
"/var/tmp/k8s-dqlite",
"tcp://127.0.0.1:12379",
true,
false,
}
return &o
}
Expand Down
7 changes: 5 additions & 2 deletions app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"fmt"
"github.com/canonical/k8s-dqlite/app/options"
"github.com/canonical/kvsql-dqlite/server"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"golang.org/x/sys/unix"
"log"
"os"
"os/signal"
"time"
Expand All @@ -39,7 +39,9 @@ var dqliteCmd = &cobra.Command{
// has an action associated with it:
Run: func(cmd *cobra.Command, args []string) {
log.Println("Starting dqlite")

if opts.Debug == true {
log.SetLevel(log.TraceLevel)
}
server, err := server.New(
opts.StorageDir,
opts.ListenEp,
Expand Down Expand Up @@ -81,4 +83,5 @@ func init() {
dqliteCmd.Flags().StringVar(&opts.StorageDir, "storage-dir", opts.StorageDir, "directory with the dqlite datastore")
dqliteCmd.Flags().StringVar(&opts.ListenEp, "listen", opts.ListenEp, "endpoint where dqlite should listen to")
dqliteCmd.Flags().BoolVar(&opts.EnableTls, "enable-tls", opts.EnableTls, "enable TlS")
dqliteCmd.Flags().BoolVar(&opts.Debug, "debug", opts.Debug, "debug logs")
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.16

require (
github.com/canonical/kvsql-dqlite v0.0.0-20210513073226-3dab903dba87
github.com/sirupsen/logrus v1.6.0
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5
golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4
Expand Down
1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ github.com/mattn/go-sqlite3
# github.com/pkg/errors v0.9.1
github.com/pkg/errors
# github.com/sirupsen/logrus v1.6.0
## explicit
github.com/sirupsen/logrus
# github.com/spf13/cobra v1.0.0
## explicit
Expand Down

0 comments on commit 451b3e7

Please sign in to comment.