Merge pull request #28891 from wojtek-t/avoid_generator_annoying_logs

Automatic merge from submit-queue

Unify logging in generators and avoid annoying logs.

@thockin regarding our discussing in the morning

@lavalamp - FYI
pull/6/head
k8s-merge-robot 2016-07-13 12:17:19 -07:00 committed by GitHub
commit 3dbc4db681
4 changed files with 17 additions and 15 deletions

View File

@ -20,14 +20,13 @@ package main
import (
"fmt"
"path/filepath"
"strings"
"k8s.io/kubernetes/cmd/libs/go2idl/args"
clientgenargs "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/args"
"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/generators"
"k8s.io/kubernetes/pkg/api/unversioned"
"strings"
"github.com/golang/glog"
flag "github.com/spf13/pflag"
)
@ -182,7 +181,7 @@ func main() {
IncludedTypesOverrides: includedTypesOverrides,
}
fmt.Printf("==arguments: %v\n", arguments)
glog.Infof("==arguments: %v\n", arguments)
}
if err := arguments.Execute(

View File

@ -22,13 +22,14 @@ import (
"go/format"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
"k8s.io/kubernetes/cmd/libs/go2idl/namer"
"k8s.io/kubernetes/cmd/libs/go2idl/types"
"github.com/golang/glog"
)
func errs2strings(errors []error) []string {
@ -63,7 +64,7 @@ type DefaultFileType struct {
}
func (ft DefaultFileType) AssembleFile(f *File, pathname string) error {
log.Printf("Assembling file %q", pathname)
glog.V(0).Infof("Assembling file %q", pathname)
destFile, err := os.Create(pathname)
if err != nil {
return err
@ -90,7 +91,7 @@ func (ft DefaultFileType) AssembleFile(f *File, pathname string) error {
}
func (ft DefaultFileType) VerifyFile(f *File, pathname string) error {
log.Printf("Verifying file %q", pathname)
glog.V(0).Infof("Verifying file %q", pathname)
friendlyName := filepath.Join(f.PackageName, f.Name)
b := &bytes.Buffer{}
et := NewErrorTracker(b)
@ -210,7 +211,7 @@ func (c *Context) addNameSystems(namers namer.NameSystems) *Context {
// import path already, this will be appended to 'outDir'.
func (c *Context) ExecutePackage(outDir string, p Package) error {
path := filepath.Join(outDir, p.Path())
log.Printf("Processing package %q, disk location %q", p.Name(), path)
glog.V(0).Infof("Processing package %q, disk location %q", p.Name(), path)
// Filter out any types the *package* doesn't care about.
packageContext := c.filteredBy(p.Filter)
os.MkdirAll(path, 0755)

View File

@ -32,6 +32,8 @@ import (
"k8s.io/kubernetes/cmd/libs/go2idl/generator"
"k8s.io/kubernetes/cmd/libs/go2idl/namer"
"k8s.io/kubernetes/cmd/libs/go2idl/types"
"github.com/golang/glog"
)
const (
@ -200,19 +202,19 @@ func (importRuleFile) VerifyFile(f *generator.File, path string) error {
return fmt.Errorf("regexp `%s` in file %q doesn't compile: %v", r.SelectorRegexp, actualPath, err)
}
for v := range f.Imports {
// fmt.Printf("Checking %v matches %v: %v\n", r.SelectorRegexp, v, re.MatchString(v))
glog.V(4).Infof("Checking %v matches %v: %v\n", r.SelectorRegexp, v, re.MatchString(v))
if !re.MatchString(v) {
continue
}
for _, forbidden := range r.ForbiddenPrefixes {
// fmt.Printf("Checking %v against %v\n", v, forbidden)
glog.V(4).Infof("Checking %v against %v\n", v, forbidden)
if strings.HasPrefix(v, forbidden) {
return fmt.Errorf("import %v has forbidden prefix %v", v, forbidden)
}
}
found := false
for _, allowed := range r.AllowedPrefixes {
fmt.Printf("Checking %v against %v\n", v, allowed)
glog.V(0).Infof("Checking %v against %v\n", v, allowed)
if strings.HasPrefix(v, allowed) {
found = true
break
@ -224,7 +226,7 @@ func (importRuleFile) VerifyFile(f *generator.File, path string) error {
}
}
if len(rules.Rules) > 0 {
fmt.Printf("%v passes rules found in %v\n", path, actualPath)
glog.V(0).Infof("%v passes rules found in %v\n", path, actualPath)
}
return nil

View File

@ -79,7 +79,7 @@ func New() *Builder {
// The returned string will have some/path/bin/go, so remove the last two elements.
c.GOROOT = filepath.Dir(filepath.Dir(strings.Trim(string(p), "\n")))
} else {
fmt.Printf("Warning: $GOROOT not set, and unable to run `which go` to find it: %v\n", err)
glog.Warningf("Warning: $GOROOT not set, and unable to run `which go` to find it: %v\n", err)
}
}
// Force this to off, since we don't properly parse CGo. All symbols must
@ -304,7 +304,7 @@ func (b *Builder) importer(imports map[string]*tc.Package, path string) (*tc.Pac
pkg, err := b.typeCheckPackage(path)
if err != nil {
if ignoreError && pkg != nil {
fmt.Printf("type checking encountered some errors in %q, but ignoring.\n", path)
glog.V(2).Infof("type checking encountered some errors in %q, but ignoring.\n", path)
} else {
return nil, err
}
@ -350,7 +350,7 @@ func (b *Builder) typeCheckPackage(id string) (*tc.Package, error) {
// method. So there can't be cycles in the import graph.
Importer: importAdapter{b},
Error: func(err error) {
fmt.Printf("type checker error: %v\n", err)
glog.V(2).Infof("type checker error: %v\n", err)
},
}
pkg, err := c.Check(id, b.fset, files, nil)
@ -685,7 +685,7 @@ func (b *Builder) walkType(u types.Universe, useName *types.Name, in tc.Type) *t
return out
}
out.Kind = types.Unsupported
fmt.Printf("Making unsupported type entry %q for: %#v\n", out, t)
glog.Warningf("Making unsupported type entry %q for: %#v\n", out, t)
return out
}
}