Add debug

This commit is contained in:
Manfred Touron 2016-11-07 08:51:13 +01:00
parent 83232e17d7
commit 9e79d2b3aa
No known key found for this signature in database
GPG Key ID: 9CCF47DF1FD978A1

View File

@ -2,6 +2,7 @@ package main
import ( import (
"bytes" "bytes"
"log"
"path/filepath" "path/filepath"
"text/template" "text/template"
@ -31,6 +32,11 @@ func NewGenericTemplateBasedEncoder(templateDir string, service *descriptor.Serv
templateDir: templateDir, templateDir: templateDir,
debug: debug, debug: debug,
} }
if debug {
log.Printf("new encoder: file=%q service=%q template-dir=%q", templateDir, service.GetName(), file.GetName())
}
return return
} }
@ -55,6 +61,9 @@ func (e *GenericTemplateBasedEncoder) templates() ([]string, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if e.debug {
log.Printf("new template: %q", rel)
}
filenames = append(filenames, rel) filenames = append(filenames, rel)
} }
@ -89,7 +98,7 @@ func (e *GenericTemplateBasedEncoder) Files() []*plugin_go.CodeGeneratorResponse
templates, err := e.templates() templates, err := e.templates()
if err != nil { if err != nil {
panic(err) log.Fatalf("cannot get templates from %q: %v", e.templateDir, err)
} }
for _, templateFilename := range templates { for _, templateFilename := range templates {