Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.

Commit df84f9a

Browse files
Add support for log verbosity (#74)
Use stdout for info and debug Use stderr for warn, error, fatal and panic
1 parent e73158f commit df84f9a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+10795
-12
lines changed

Gopkg.lock

Lines changed: 19 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

binary/etcd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ package binary
1919
import (
2020
"fmt"
2121
"io/ioutil"
22-
"log"
2322
"os"
2423
"os/exec"
2524
"path/filepath"
2625
"strings"
2726
"time"
2827

28+
log "github.com/platform9/etcdadm/pkg/logrus"
29+
2930
"github.com/platform9/etcdadm/constants"
3031
"github.com/platform9/etcdadm/util"
3132
)

certs/certs.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import (
2525
"crypto/rsa"
2626
"crypto/x509"
2727
"fmt"
28-
"log"
28+
29+
log "github.com/platform9/etcdadm/pkg/logrus"
2930

3031
"github.com/platform9/etcdadm/apis"
3132
"github.com/platform9/etcdadm/certs/pkiutil"

cmd/download.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package cmd
1818

1919
import (
20-
"log"
20+
log "github.com/platform9/etcdadm/pkg/logrus"
2121

2222
"github.com/platform9/etcdadm/apis"
2323
"github.com/platform9/etcdadm/binary"

cmd/info.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import (
2020
"context"
2121
"encoding/json"
2222
"fmt"
23-
"log"
23+
24+
log "github.com/platform9/etcdadm/pkg/logrus"
2425

2526
"github.com/platform9/etcdadm/apis"
2627
"github.com/platform9/etcdadm/constants"

cmd/init.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ package cmd
1818

1919
import (
2020
"context"
21-
"log"
2221
"os"
2322

23+
log "github.com/platform9/etcdadm/pkg/logrus"
24+
2425
"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
2526
"github.com/platform9/etcdadm/etcd"
2627

cmd/join.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ package cmd
1818

1919
import (
2020
"context"
21-
"log"
2221
"net/url"
2322
"os"
2423

24+
log "github.com/platform9/etcdadm/pkg/logrus"
25+
2526
"github.com/coreos/etcd/etcdserver/etcdserverpb"
2627

2728
"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"

cmd/reset.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ package cmd
1818

1919
import (
2020
"context"
21-
"log"
2221
"os"
2322

23+
log "github.com/platform9/etcdadm/pkg/logrus"
24+
2425
"github.com/coreos/etcd/etcdserver/etcdserverpb"
2526
"github.com/platform9/etcdadm/apis"
2627
"github.com/platform9/etcdadm/binary"

cmd/root.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,25 @@ import (
2121
"os"
2222

2323
"github.com/platform9/etcdadm/apis"
24+
log "github.com/platform9/etcdadm/pkg/logrus"
25+
"github.com/sirupsen/logrus"
2426
"github.com/spf13/cobra"
2527
)
2628

2729
var etcdAdmConfig apis.EtcdAdmConfig
30+
var LogLevel string
2831

2932
var (
3033
rootCmd = &cobra.Command{
3134
Use: "etcdadm",
3235
Long: `Tool to bootstrap etcdadm on the host`,
36+
PersistentPreRun: func(cmd *cobra.Command, args []string) {
37+
logLevel, err := logrus.ParseLevel(LogLevel)
38+
if err != nil {
39+
log.Fatalf("Could not parse log level %v", logLevel)
40+
}
41+
log.SetLogLevel(logLevel)
42+
},
3343
}
3444
)
3545

@@ -39,3 +49,7 @@ func Execute() {
3949
os.Exit(1)
4050
}
4151
}
52+
53+
func init() {
54+
rootCmd.PersistentFlags().StringVarP(&LogLevel, "log-level", "l", "info", "set log level for output, permitted values debug, info, warn, error, fatal and panic")
55+
}

cmd/version.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ package cmd
1919
import (
2020
"encoding/json"
2121
"fmt"
22-
"log"
22+
23+
log "github.com/platform9/etcdadm/pkg/logrus"
2324

2425
"github.com/ghodss/yaml"
2526
"github.com/spf13/cobra"

0 commit comments

Comments
 (0)