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