Skip to content

Commit

Permalink
Merge pull request #8024 from stevekuznetsov/skuznets/glog
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed May 2, 2016
2 parents d33c8ab + 5963a5c commit b50fa54
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
8 changes: 8 additions & 0 deletions Godeps/_workspace/src/github.com/golang/glog/glog.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pkg/cmd/server/start/start_allinone.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type AllInOneOptions struct {
NodeConfigFile string
PrintIP bool
ServiceNetworkCIDR string
Output io.Writer
}

const allInOneLong = `
Expand All @@ -59,7 +60,7 @@ You may also pass --kubeconfig=<path> to connect to an external Kubernetes clust

// NewCommandStartAllInOne provides a CLI handler for 'start' command
func NewCommandStartAllInOne(basename string, out io.Writer) (*cobra.Command, *AllInOneOptions) {
options := &AllInOneOptions{MasterOptions: &MasterOptions{Output: out}}
options := &AllInOneOptions{Output: out, MasterOptions: &MasterOptions{Output: out}}
options.MasterOptions.DefaultsFromName(basename)

cmds := &cobra.Command{
Expand Down Expand Up @@ -227,7 +228,7 @@ func (o AllInOneOptions) StartAllInOne() error {
if err != nil {
return err
}
fmt.Fprintf(o.MasterOptions.Output, "%s\n", host)
fmt.Fprintf(o.Output, "%s\n", host)
return nil
}
masterOptions := *o.MasterOptions
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/server/start/start_master.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (o MasterOptions) CreateCerts() error {
APIServerCAFiles: o.MasterArgs.APIServerCAFiles,
CABundleFile: admin.DefaultCABundleFile(o.MasterArgs.ConfigDir.Value()),
PublicAPIServerURL: publicMasterAddr.String(),
Output: o.Output,
Output: cmdutil.NewGLogWriterV(3),
}
if err := mintAllCertsOptions.Validate(nil); err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/server/start/start_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
configapi "github.com/openshift/origin/pkg/cmd/server/api"
configapilatest "github.com/openshift/origin/pkg/cmd/server/api/latest"
"github.com/openshift/origin/pkg/cmd/server/api/validation"
cmdutil "github.com/openshift/origin/pkg/cmd/util"
"github.com/openshift/origin/pkg/cmd/util/docker"
utilflags "github.com/openshift/origin/pkg/cmd/util/flags"
"github.com/openshift/origin/pkg/version"
Expand Down Expand Up @@ -257,7 +258,7 @@ func (o NodeOptions) CreateNodeConfig() error {
APIServerCAFiles: []string{admin.DefaultCABundleFile(o.NodeArgs.MasterCertDir)},

NodeClientCAFile: getSignerOptions.CertFile,
Output: o.Output,
Output: cmdutil.NewGLogWriterV(3),
}

if err := createNodeConfigOptions.Validate(nil); err != nil {
Expand Down
26 changes: 25 additions & 1 deletion pkg/cmd/util/log.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package util

import "github.com/golang/glog"
import (
"io"

"github.com/golang/glog"
)

// GetLogLevel returns the current glog log level
func GetLogLevel() (level int) {
Expand All @@ -11,3 +15,23 @@ func GetLogLevel() (level int) {
}
return
}

// NewGLogWriterV returns a new Writer that delegates to `glog.Info` at the
// desired level of verbosity
func NewGLogWriterV(level int) io.Writer {
return &gLogWriter{
level: glog.Level(level),
}
}

// gLogWriter is a Writer that writes by delegating to `glog.Info`
type gLogWriter struct {
// level is the default level to log at
level glog.Level
}

func (w *gLogWriter) Write(p []byte) (n int, err error) {
glog.V(w.level).InfoDepth(2, string(p))

return len(p), nil
}

0 comments on commit b50fa54

Please sign in to comment.